Ask Your Question

How to convert specific sheet to CSV via command line? [closed]

asked 2015-02-18 23:27:42 +0100

Mikeyy gravatar image

updated 2020-08-02 14:28:41 +0100

Alex Kemp gravatar image

Looking at this question and answers ( ), plus checking some other resources, I found out that you can batch convert spreadsheet files to CSV. This is command you can use:

soffice --headless --convert-to csv:"Text - txt - csv (StarCalc)":"59,ANSI,1" test.ods

Only problem I have is, I don't want to convert first/default sheet. I want to convert specific sheet (defined by order number or name). Does anyone know how to convert specific sheet with this command? My guess is that opening spreadsheet file in specific sheet and then converting would work also, but not sure how to do that via command line.

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by Alex Kemp
close date 2020-08-02 14:29:11.586301

1 Answer

Sort by » oldest newest most voted

answered 2015-03-26 13:55:00 +0100

0TOJ5 gravatar image

updated 2015-03-26 15:46:30 +0100

This worked for me to convert multiple ODS spreadsheet files with multiple sheets to separate CSV files:

Convert ODS to XLSX

libreoffice --headless --convert-to xlsx ./* --outdir ./spreadsheet-xlsx/

Convert XLSX to CSV

cd ./spreadsheet-xlsx/

for i in 2 3 4; do
    for j in $(ls -1 | sed -e 's/\..*$//'); do
    xlsx2csv -s $i $j.xlsx ../spreadsheet-csv/$j-$i.csv
edit flag offensive delete link more


Just to mention where to obtain xlsx2csv, it is available from GitHub.

erAck gravatar imageerAck ( 2015-09-11 00:19:20 +0100 )edit

Yes, that could work, but since my spreadsheet in quite complex, converting from ods to xlsx would probably destroy something. + it's longer way :) Anyway, thanks for solution.

Mikeyy gravatar imageMikeyy ( 2015-10-20 18:24:02 +0100 )edit

Question Tools



Asked: 2015-02-18 23:27:42 +0100

Seen: 32,844 times

Last updated: Mar 26 '15