how to convert xlsx to csv in unix

11,939

For a .xlsx with multiple sheets, you have to export each sheet as a separate .csv file. Of course different files must have different names.

You could either name the sheets by a number, using %n

ssconvert --export-file-per-sheet "$filename.xlsx" "$filename-%n.csv"

or name the sheets by their names, using %s

ssconvert --export-file-per-sheet "$filename.xlsx" "$filename-%s.csv"

Instead of --export-file-per-sheet you can also use the shorthand notation -S with exactly the same effect.

Share:
11,939
Midhun
Author by

Midhun

Updated on June 04, 2022

Comments

  • Midhun
    Midhun about 2 years

    I have a text file (abc.txt) which will be having the file name along with the path which is to be converted to .csv.

    I am getting error saying that

    Selected exporter does not support saving multiple sheets in one file.

    Only the current sheet will be saved. But it not getting saved for one tab as well.

    Below is the query that I have wrote

    #!/bin/bash
    CURRENT_DATE=date +'%d%m%Y'
    Temp_Path=/my/first/path
    cd $Temp_Path
    #rm INBOUND_XLSX_FILES_.txt
    find /my/second/path -name ".xlsx" >> "$Temp_Path/conversion.txt"
    while IFS= read -r "f" ; do
        filename="${f%.*}"
        ssconvert "${filename}".xls
        "${filename}".csv
    done < conversion.txt
    
  • Midhun
    Midhun over 7 years
    I tried the same, but i am getting error: ssconvert --export-file-per-sheet "MomAndPop_Metadata_3-9-17_Approved.xlsx" "MomAndPop_Metadata_3-9-17_Approved.csv" Reading file:///appinfprd/bi//IRP/IRPVendors/MomAndPop_Metadata_3-9-‌​17_Approved.xlsx ** (ssconvert:19946): WARNING **: TODO ** (ssconvert:19946): CRITICAL **: wb_view_save_as: assertion IS_WORKBOOK_VIEW (wbv)' failed ** (ssconvert:19946): CRITICAL **: wb_view_workbook: assertion IS_WORKBOOK_VIEW (wbv)' failed (ssconvert:19946): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed
  • Socowi
    Socowi over 7 years
    Then you should have mentioned that in your question. You still can (and in this case should) edit your question after posting it. Regarding the error: Even though I don't see a %n or %s in your command, the error message looks like there is a bug in ssconvert.