I am using LibreOffice 5.0.5.2 in an Ubuntu 15.10 docker container to convert arbitrary incoming spread sheet files into canonical CSV files:
/usr/lib/libreoffice/program/soffice.bin \
--convert-to 'csv:Text - txt - csv (StarCalc):44,34,76,1,1/2/2/2/3/2,1031,true,false,true' \
--outdir '/tmp/outgoing' \
'incoming.csv'
As I understand the documentation, this command line should faithfully convert spread sheets to a CSV, using:
,
as a field separator ("44")"
as an enclosure character ("34")- UTF-8 as the incoming encoding ("76")
- start with the first row in the file ("1")
- format columns 1, 2, and 3 as text ("1/2/2/2/3/2"),
- use UTF-8 has the outgoing encoding ("1031")
- quote all text cells ("true")
- do not detect special numbers ("false")
- save cell contents as shown ("true")
This works well, except for columns that contain certain text with leading zeroes. For example, if incoming.csv
is this:
"0123456789"
The resulting exported file is this:
123456789
My understanding is that if the column is marked as text on import, that will retain the leading zeroes, and then going the other way, marking "quote all text cells" on export will keep those preserved zeroes. But that does not appear to be the case for some set of inputs.
For example, these keep their leading zeroes, which I presume is because they contain non-numeric characters:
0x3E
0 123 456
Using the command line, how can I coax LibreOffice to keep the leading zeroes during export?