I'm looking for a way to convert xlsx files to csv files on Linux.
I do not want to use PHP/Perl or anything like that since I'm looking at processing several millions of lines, so I need something quick. I found a program on the Ubuntu repos called xls2csv but it will only convert xls (Office 2003) files (which I'm currently using) but I need support for the newer Excel files.
Any ideas?
Another option would be to use R via a small bash wrapper for convenience:
You can do this with LibreOffice:
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:
Use csvkit
For details check their excellent docs
In bash, I used this libreoffice command to convert all my xlsx files in the current directory:
It takes care of spaces in the filename.
Tried again some years later, and it didn't work. This thread gives some tips, but the quickiest solution was to run as root (or running a
sudo libreoffice
). Not elegant, but quick.Use the command scalc.exe in Windows
If you already have a Desktop environment then I'm sure Gnumeric / LibreOffice would work well, but on a headless server (such as Amazon Web Services), they require dozens of dependencies that you also need to install.
I found this Python alternative:
https://github.com/dilshod/xlsx2csv
Took 2 seconds to install and works like a charm.
If you have multiple sheets you can export all at once, or one at a time:
He also links to several alternatives built in Bash, Python, Ruby, and Java.
Using the Gnumeric spreadsheet application which comes which a commandline utility called ssconvert is indeed super simple:
and you're done!