[Solved] Always open CSV files as UTF-8 English?

Discuss the spreadsheet application
Post Reply
collector dave
Posts: 5
Joined: Sun Oct 25, 2020 5:06 am

[Solved] Always open CSV files as UTF-8 English?

Post by collector dave »

I have several hundred CSV files all created with OO. All are always save with UTF8 and english.

Just recently I noticed some errors creeping in so checked.

I saved a .ODF document as CSV UTF 8 English Then reopened the same document it attempted to open it with UTF 7 and Turkish? The contents looked a right mess.

Ok when you are fully awake but if just trusting to OO it can create confusion.

Is there any way to get OO to always open CSV files as UTF 8 English?
Last edited by robleyd on Wed Oct 28, 2020 8:00 am, edited 2 times in total.
Reason: Add green tick
openoffice 4.1.7

MACOS Mojave
User avatar
RusselB
Moderator
Posts: 6646
Joined: Fri Jan 03, 2014 7:31 am
Location: Sarnia, ON

Re: Save/load CSV

Post by RusselB »

Welcome to the Forums.
Your best bet is to save your files using the default Open Document Format, which uses the .ods extension.
There are a lot of formats that qualify for .csv and it really isn't the best option.
What, if any, reason are you forcing the save using the .csv format? We might be able to provide a better option if we understand your reasoning for using the .csv format.
OpenOffice 4.1.7, LibreOffice 7.0.1.2 on Windows 7 Pro, Ultimate & Windows 10 Home (2004)
If you believe your problem has been resolved, please go to your first post in this topic, click the Edit button and add [Solved] to the beginning of the Subject line.
Bill
Volunteer
Posts: 8952
Joined: Sat Nov 24, 2007 6:48 am

Re: Save/load CSV

Post by Bill »

collector dave wrote:Is there any way to get OO to always open CSV files as UTF 8 English?
When you open the document, change the settings on the Text Import dialog. My tests show that those settings are sticky, at least on my system. They are not imported from the document being opened.
AOO 4.1.14 on Ubuntu MATE 22.04
collector dave
Posts: 5
Joined: Sun Oct 25, 2020 5:06 am

Re: Save/load CSV

Post by collector dave »

Hi all

It is for an application I have written which is quite data intensive.

When a user wishes to export some data I create a CSV export file of the data.

The user may add more data or make corrections and then save the file again to return to me or another user who can then import the file back into the database.

Everything works fine until any one user forgets to check the import settings then saves the file.

The export needs to be readable by the user easily as some may want to use the information directly.

I have thought of using ODS files and I have had some success creating an ODS file directly but it stretches my meagre programming skills to the limit.

If there is another format which can be created easily that removes the need for the user to notice the settings I would swap to that in a flash.

Hope this explains it a little better.

Kind Regards

CD
openoffice 4.1.7

MACOS Mojave
Mountaineer
Posts: 340
Joined: Sun Sep 06, 2020 8:27 am

Re: Save/load CSV

Post by Mountaineer »

Hello,

the problem is, csv don't transport any information how it is saved. You may have a first line with titels for columns, but no charset.

In your position I'd check, if there is a possibility to generate an dBase-File, wich can carry a language driver id. These can be opened by LibreOffice directly (like csv), but if the id is set, there is no need to ask you for a charset. Users can even modify and save the file.

One drawback: As this is an old standard, there is no code for Unicode/utf-8 - as far as I know - so you may have to convert Text to some historic Windows/ANSI oder other 8bit Charset.

J
LibreOffice 7.6 on Windows 10pro and other Versions parallel
collector dave
Posts: 5
Joined: Sun Oct 25, 2020 5:06 am

Re: Save/load CSV

Post by collector dave »

Thanks for the replies.

I have given up on CSV now, as you all said no info is included as to charset etc.

The problems get even worse when some application other than openOffice is used.

I sat myself down and have started to write an Export/Import module direct to ODS and am having some success. Once tested I will be exporting data only in ODS format.

Kind regards

collectordave
openoffice 4.1.7

MACOS Mojave
User avatar
Villeroy
Volunteer
Posts: 31365
Joined: Mon Oct 08, 2007 1:35 am
Location: Germany

Re: Save/load CSV

Post by Villeroy »

What is the other application you exchange data with? If it happens to be a common database, there are chances that you can use the database directly without any import/export.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
collector dave
Posts: 5
Joined: Sun Oct 25, 2020 5:06 am

Re: Always open CSV files as UTF-8 English?

Post by collector dave »

That is the rub.

The other application can be anything the user wishes.

The database is a distributed database that the user can modify to their own requirements to a certain extent.

The only solution I can think of is to read & write ODS files directly. This means that each user will need to use OpenOffice or Libre Office to open the file from which they can modify the file or export in a format of their own choosing.

I now have a working solution though a little shaky as yet, I can write an ODS sheet and read the contents of an ODS sheet. Just need to refine it a little more.

Regards

collectordave
openoffice 4.1.7

MACOS Mojave
Mountaineer
Posts: 340
Joined: Sun Sep 06, 2020 8:27 am

Re: [Solved] Always open CSV files as UTF-8 English?

Post by Mountaineer »

So some of your clients may use Access, some SQLITE,
some mySQL and some dBase?

That's no distributed but just a bunch of files...
Has your database a name, where we can check for details or did you write it?

If there is a common file-structure it may be possible to connect them directly to base. I'n using a setup in Sqlite for some laptops which work offline while out of the shop.

If nobody changes the charset it may even be possible to use the csv-files as a Text-Table in Base. But as it was said above there is no protection against manual overrides for csv.

J.

PS there are bindings for Sqlite available for most programming languages.
LibreOffice 7.6 on Windows 10pro and other Versions parallel
John_Ha
Volunteer
Posts: 9606
Joined: Fri Sep 18, 2009 5:51 pm
Location: UK

Re: [Solved] Always open CSV files as UTF-8 English?

Post by John_Ha »

collector dave wrote:Is there any way to get OO to always open CSV files as UTF 8 English?
1. csv files do not store content relating to how they should be opened.
2. the settings you use to open a csv file are sticky in AOO or LO and will be used/offered next time you open a csv file.
3. you could record a macro which set the settings to the correct value and require that people run the macro before opening any csv file.
4. you could automate their AOO or LO (Tools > Customise > Events) so the macro always runs when they start AOO or Calc so the settings are always pre-set.
5. Stop using csv format and use .odt files.
LO 6.4.4.2, Windows 10 Home 64 bit

See the Writer Guide, the Writer FAQ, the Writer Tutorials and Writer for students.

Remember: Always save your Writer files as .odt files. - see here for the many reasons why.
collector dave
Posts: 5
Joined: Sun Oct 25, 2020 5:06 am

Re: [Solved] Always open CSV files as UTF-8 English?

Post by collector dave »

The database is one I have written using sqlite as the engine. Actually it is four databases three used for client specific information and only available on the clients machine.

Every client receives a copy of the main databases when starting to use the system. These can then be modified by the client by adding or amending the data.

The problem is in sharing data between clients. I thought CSV was good but then some clients open the csv file in Xhell which appears to be the worst.

I have to assume that none of my clients are computer savvy so asking them to check the settings before opening the csv is a non starter (tried before).

Of course the settings are persistent on my machine but are not sent to a clients machine.

I am now moving towards exporting the data in ODS format and requiring my clients to us AOO or LO to open them. What they do with the data after that then becomes their concern.
openoffice 4.1.7

MACOS Mojave
Post Reply