by Oliver
13. November 2015 21:54
Thanks to this stackoverflow answer I stumbled upon the comment by Aryeh Leib Taurog who shared his solution and a link to the OpenOffice documentation on the available options for the CSV filter.
Here's how to convert the file input.xlsx to the UTF-8 encoded file input.csv in the current directory, with semicolons as field delimiter:
soffice.exe --convert-to "csv:Text - txt - csv (StarCalc):59,,76,1" input.xlsx
On my Windows system the soffice.exe is located under C:\Program Files\LibreOffice 5\program.
Hre's the explanation of the cryptic filter arguments:
- csv – the extension of the output file
- Text - txt - csv (StarCalc) – the (ancient) name of the filter (kept for compatibility)
- 59,,76,1 – these are four arguments:
- the first parameter is the delimiter in the output file – 59 is the ASCII code for ';'
- the second parameter is the text delimiter – it's missing because I don't want to wrap text in quotes
- the third parameter is the file encoding – 76 is the internal OpenOffice code for UTF-8 (from the table on the documentation page)
- the fourth parameter defines the line number with which to start the export – here, we start with line 1
Thank you, open source community, and happy converting!
PS: For non-windows users, Gnumeric with its command line tool ssconvert might be a good choice for this job, as well.