Ask Your Question

Is is possible to convert comma-separated value (CSV) to tab-separated value (TSV) via headless mode? [closed]

asked 2013-06-15 01:24:10 +0200

Synapse gravatar image

updated 2014-10-01 02:33:35 +0200

oweng gravatar image

Hi, is it possible to convert csv or xls to tsv format? Specifically in headless mode. I have tried converting using the following:

libreoffice --headless --convert-to tsv "foo.csv"

but the output is garbled and full of unprintable characters.

Thanks for any help

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Alex Kemp
close date 2016-03-04 16:17:54.590117


loffice "-env:UserInstallation=file:///tmp/LibO_Conversion" --convert-to csv:"Text - txt - csv (StarCalc)":9,34,UTF8 --headless --outdir some/path --infilter='csv:44,34,UTF8' some.csv works fine on 5.3 for me. Should be reopened and added as an answer IMO, it's very hard to put this command line together from the available documentation.

chx gravatar imagechx ( 2017-04-20 00:58:23 +0200 )edit

1 Answer

Sort by » oldest newest most voted

answered 2013-06-15 02:17:01 +0200

oweng gravatar image

updated 2014-10-01 02:22:08 +0200

A comma/character-separated value (CSV) or delimiter-separated value (DSV) file can use a comma, semi-colon, tab, or any other character, to separate the values. The related output filter is txt:"Text - txt - csv (StarCalc)" (which can also be used as csv:"Text - txt - csv (StarCalc)" and even tsv:"Text - txt - csv (StarCalc)"). Unfortunately though, the headless / convert-to mode for LO is used to convert between formats that LO can read/write rather than adjust an existing format (e.g., CSV from commas to tabs). Even the recent changes made in fdo#36313 (v4.4) to allow specifying of the delimiter and text quotation mark to support UTF-8 encoding (e.g., --infilter=CSV:59,34,UTF8) do not appear to assist in this respect.

Why not simply do a find/replace externally on the file to convert the commas to tabs? Use a regular expression if you have to (to ensure you don't pick-up data by mistake).

edit flag offensive delete link more


A CSV file is traditionally a Comma, not Character, separated file. Commas were a pretty bad delimiter choice in the first place, and "correcting" this error by allowing any character has made a bad format more ambiguous. There are of course such things as TSV files, which is why Excel supports them for input and output. One of the few annoying things about LibreOffice is that it does so less well, thereby limiting its use within scientific fields which are chuck full of TSV files.

iggie gravatar imageiggie ( 2014-09-30 19:36:23 +0200 )edit

Re. TSV, fair enough. Whitespace of any kind will always make for a poorer choice in delimiter than a visual character. I will edit the question. Perhaps we should all use delimiter-separated value (DSV).

oweng gravatar imageoweng ( 2014-10-01 01:52:38 +0200 )edit

Question Tools


Asked: 2013-06-15 01:24:10 +0200

Seen: 5,232 times

Last updated: Oct 01 '14