Escape or replace double quotes when converting from xls to csv

asked 2016-03-04 23:39:13 +0100

mikeg gravatar image

updated 2016-03-07 13:58:05 +0100

Alex Kemp gravatar image

I am trying to convert some .xls files .csv files using the command line on a Linux system (Ubuntu 14.04, LO v 4.2.8) using the following command

$ libreoffice "-env:UserInstallation=file:///tmp/LibO_Conversion" --headless --invisible --convert-to csv "$INFILE"

Unfortunately, I am running into problems doing this because some of the cells in the .xls file include text with double quotes (") and commas. As a result there are situations where it is ambiguous as to where a particular cell begins or ends in the .csv file I create. I am wondering if it's possible to pass arguments to LibreOffice during the conversion process so that the double quotes within a cell are converted to \" or even single quotes (').

Can anyone provide me with some suggestions on how to do this?

edit retag flag offensive close merge delete


Test if doing first through the IU right, the options are retained for the command line.

m.a.riosv gravatar imagem.a.riosv ( 2016-03-05 01:00:56 +0100 )edit

Hmmm good idea. I might be able to figure out a work around using ';' as my separation value and making sure all cells are quoted. However, I don't see how I can indicate I want to do that using the command line. Any suggestions?

mikeg gravatar imagemikeg ( 2016-03-05 01:14:35 +0100 )edit

After you have getting from UI, try from command line, I think options used in UI are retained and used from command line.

m.a.riosv gravatar imagem.a.riosv ( 2016-03-05 01:19:44 +0100 )edit