3

I'm trying to convert xls files in a directory to csv format using soffice.

    soffice --headless --convert-to csv *

It is giving comma separated version(obviously). Now I want to get semi-colon delimited csv.

I thought of replacing commas with semi-colons using vim command.

    :%s/,/;/g

But it's not correct, as it replaces commas which are kept intentionally in original content. It has to delimit while converting from xls to csv.

How to get semi-colon delimited csv with soffice command line?

lcd047
  • 5,731
  • 2
  • 28
  • 38
srand9
  • 337
  • 1
  • 6
  • 20
  • 1
    `soffice --convert-to csv:"Text - txt - csv (StarCalc)":59,34,0,1,1 -outdir /some/path *`. See the [wiki](https://wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Filter_Options) for more details . – lcd047 Jun 15 '16 at 11:08
  • 1
    @lcd047, _:"Text - txt - csv (StarCalc)"_ is for filtering input files and numbers are for selecting encoding format. There's no option in [wiki](https://wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Filter_Options) to change delimiter. – srand9 Jun 15 '16 at 12:43
  • 2
    Have you actually tried the command line I mentioned? Read again the section [Filter Options for the CSV Filter](https://wiki.openoffice.org/wiki/Documentation/DevGuide/Spreadsheets/Filter_Options#Filter_Options_for_the_CSV_Filter). The separator is the first number. `44` in the wiki is the (decimal) ASCII code for comma, while `59` above is the ASCII code for semicolon. – lcd047 Jun 15 '16 at 19:16
  • @lcd047, I did try that. It has returned an error saying to re-verify input parameters. Somehow, I missed some part of wiki page. I will go through it again. – srand9 Jun 16 '16 at 03:41
  • @lcd047, your solution worked super fine. The reason, it has thrown an error was libre office version. I am using 'LibreOffice 4.2.8.2 420(Build:2)' in which ouput_filter_options are not supported. It worked fine with LO 4.3* version. Thanks. I'm posting it as answer :) – srand9 Jun 16 '16 at 05:05

1 Answers1

3

Finally, I got an answer. Adding output_filter_options worked like a charm.

    --convert-to output_file_extension[:output_filter_name[:output_filter_options]] [--outdir output_dir] files

This wiki link helped. Here is what I did,

    soffice --headless --convert-to csv:"Text - txt - csv (StarCalc)":59,34,0,1,1 *.xls

NOTE: It works with libre office 4.3 or higher version.

srand9
  • 337
  • 1
  • 6
  • 20