Saturday, May 2, 2015

How to convert xlsx files to csv using libreoffice headless command.

First if you want to convert the xlsx file to csv file,it is possible using libreoffice.
First check if libreoffice is installed on your machine.
To check that type "libreoffice" on console.

If a prompt comes up,then it is evident that libre office is installed.





we don't need to have to open libreoffice calc for converting the xlsx to csv.
we can do this using the headless mode,using the following command.
format :--
libreoffice --headless --convert-to output_file_extension output_filter_name --outdir output_dir
command example
libreoffice --headless --convert-to csv filename.xlsx --outdir .
Here the filename.xlsx is your xlsx to be converted to csv.

Note:- If the above command does not work in the normal mode use sudo,
or add following line to your sudors file.

users ALL=(ALL) NOPASSWD: libreoffice
Now see the .xlsx is converted to csv and is present in the current directory.
Now xlsx is converted to csv,dissecting a column in csv is one usecase.
and search for a matching string is one more usecase.
and find the unique occurances of that string is another usecase.

No comments:

Post a Comment