Linux: Convert xlsx to csv in Linux with command line

Linux: Convert xlsx to csv in Linux with command line

Asked on October 23, 2018 in Linux.
Add Comment


  • 6 Answer(s)

    The Gnumeric spreadsheet application comes with a command line utility called ssconvert that can convert between a variety of spreadsheet formats:

    $ ssconvert Book1.xlsx newfile.csv
    Using exporter Gnumeric_stf:stf_csv
    $ cat newfile.csv
    Foo,Bar,Baz
    1,2,3
    123.6,7.89,
    2012/05/14,,
    The,last,Line
    

    To install on Ubuntu:

    apt-get install gnumeric

    To install on Mac:

    brew install gnumeric
    
    Answered on October 23, 2018.
    Add Comment

    Try libre office

    libreoffice --headless --convert-to csv $filename --outdir $outdir
    
    

    For reasons not clear to me, you might need to run this with sudo. You can make LibreOffice work with sudo without requiring a password by adding this line to you sudoers file:

    users ALL=(ALL) NOPASSWD: libreoffice
    
    
    Answered on October 23, 2018.
    Add Comment

    Use csvkit

    in2csv data.xlsx > data.csv
    
    
    Answered on October 23, 2018.
    Add Comment

    5 Methods to Convert xlsx Format Files to CSV on Linux CLI. XLSX is a file extension for an open XML spreadsheet file format used by MicrosoftExcel.Converting Microsoft Excel sheet to a Comma Separated file (CSV) is relatively very easy while using command line.

    1
    libreoffice --headless --convert-to csv $filename --outdir $outdir

    For reasons not clear to me, you might need to run this with sudo. You can make LibreOffice work with sudo without requiring a password by adding this line to you sudoers file:

    1
    users ALL=(ALL) NOPASSWD: libreoffice
    Answered on January 16, 2019.
    Add Comment

    Another option would be to use R via a small bash wrapper for convenience:

    xlsx2txt(){
    echo '
    require(xlsx)
    write.table(read.xlsx2(commandArgs(TRUE)[1], 1), stdout(), quote=F, row.names=FALSE, col.names=T, sep="\t")
    ' | Rscript --vanilla - $1 2>/dev/null
    }
    
    xlsx2txt file.xlsx > file.txt
    Answered on January 16, 2019.
    Add Comment

    The Gnumeric spreadsheet application comes with a command line utility called ssconvert that can convert between a variety of spreadsheet formats:

    $ ssconvert Book1.xlsx newfile.csv
    Using exporter Gnumeric_stf:stf_csv
    
    $ cat newfile.csv 
    Foo,Bar,Baz
    1,2,3
    123.6,7.89,
    2012/05/14,,
    The,last,Line
    

    To install on Ubuntu:

    apt-get install gnumeric
    

    To install on Mac:

    brew install gnumeric
    
    Answered on February 21, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.