Excel is an Microsoft spreadsheet program and its extension is .xls or .xlsx. Now we as Linux user can convert xls file to csv file in Linux and .xls to .csv. This quick guide will help you how we can convert xls file to csv file in Linux using program called SSConvert and Unoconv.
Convert xls file to csv file in Linux.
1. Installing SSConvert to convert xls file to csv file in Linux
For REDHAT ,CENTOS and FEDORA.
yum install gnumeric
For UBUNTU and DEBIAN.
apt-get install gnumeric
Now to show demo on how to convert xls file to csv file in Linux. I am creating sample csv file as below:
# cat example.csv surname,name,age Manmohan,Mirkar,23 Vikrant,Shinde,46 Nilesh,Patil,69 Vipul,Marathe,23 #
So Firstly we will convert this file to xls.
# ssconvert example.csv myexcel.xls
In case you need xlsx file extension use below command:
# ssconvert example.csv myexcel.xlsx
You can also reconfirm file type using the file command as below:
# file example.csv example.csv: ASCII text, with CRLF line terminators # file myexcel.xls myexcel.xls: Composite Document File V2 Document, Little Endian, Os: Windows, Version 4.10, Code page: 1252, Create Time/Date: Tue May 2 13:30:10 2017 # file myexcel.xlsx myexcel.xlsx: Microsoft OOXML #
Now lets convert this xls back to new csv file.
# ssconvert myexcel.xls mynewcsv.csv # file mynewcsv.csv mynewcsv.csv: ASCII text # cat mynewcsv.csv surname,name,age Manmohan,Mirkar,23 Vikrant,Shinde,46 Nilesh,Patil,69 Vipul,Marathe,23 #
Even you can change the delimiter other than comma if you want. So lets take “;” as delimiter.
# ssconvert -O 'separator=; format=raw' myexcel.xls new_delimitor.txt # file new_delimitor.txt new_delimitor.txt: ASCII text # cat new_delimitor.txt surname;name;age Manmohan;Mirkar;23 Vikrant;Shinde;46 Nilesh;Patil;69 Vipul;Marathe;23 #
2. Installing unoconv program to convert xls file to csv file in Linux
For REDHAT ,CENTOS and FEDORA.
yum install unoconv
For UBUNTU and DEBIAN.
apt-get install unoconv
For showing demo to convert xls file to csv file in Linux we will be renaming our old example file as example1.csv.
# cp example.csv example1.csv # cat example1.csv surname,name,age Manmohan,Mirkar,23 Vikrant,Shinde,46 Nilesh,Patil,69 Vipul,Marathe,23 #
Now lets convert this “example1.csv” to xls file.
#unoconv --format xls example1.csv
This will create new “example1.xls” file in the same directory. In case you want to convert to xlsx format command would be:
# unoconv --format xlsx example1.csv
Now lets convert xls file to csv file in Linux.
#unoconv --format csv example1.xls
Now lets check the file type of the generated files:
# file example1.xls example1.xls: Composite Document File V2 Document, Little Endian, Os: Windows, Version 1.0, Code page: -535, Revision Number: 0 # file example1.xlsx example1.xlsx: Microsoft OOXML # file example1.csv example1.csv: ASCII text #
Leave a Reply