Converting huge xls(having multiple tabs) to csv


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Converting huge xls(having multiple tabs) to csv
# 1  
Old 01-10-2012
Converting huge xls(having multiple tabs) to csv

hello

I have browsed for the similar requirement i found this

https://www.unix.com/shell-programmin...onversion.html

but my problem is i have multiple tabs in xls file having same metadata

I want to convert it into single csv file

any ways to do it pls suggest

Note : I tried saving file by save as to csv but this will only save current tab to csv not all tabs

thanks in advance
# 2  
Old 01-10-2012
Are you comfortable w using Perl? There are a few modules that parse/read-write excel formats.
# 3  
Old 01-10-2012
Quote:
Originally Posted by curleb
Are you comfortable w using Perl? There are a few modules that parse/read-write excel formats.
thanks for quick reply but I will prefer unix scripts as I am not that much confortable with perl
# 4  
Old 01-10-2012
I have used a tool xls2csv from the package 'catdoc' successfully before.
I believe it separates tabs with some special character, ^L (octal 014) I. believe. I think you need a xls version from office XP/2003, not the newest xlsx stuff.

You could try this to separate the tabs:
Code:
xls2csv excelfile.xls  | awk '{print > "tab"NR".csv"}' RS="\014"

This should create files tab1.csv, tab2.csv, etc. one for each tab.
# 5  
Old 01-10-2012
Quote:
Originally Posted by mirni
I have used a tool xls2csv from the package 'catdoc' successfully before.
This should create files tab1.csv, tab2.csv, etc. one for each tab.
Thanks for this useful post but I have very limited privilege to access tools that's the main reason I am looking for any unix script base solution if possible
# 6  
Old 01-10-2012
That's too bad. Making sense of the MS Office format is not a trivial task...
Have you looked at this?
XLS to CSV [Archive] - FedoraForum.org

It describes how to create a macro, to save all tabs as csv.

---------- Post updated at 02:22 AM ---------- Previous update was at 01:51 AM ----------

Quote:
Originally Posted by joshiamit
Thanks for this useful post but I have very limited privilege to access tools that's the main reason I am looking for any unix script base solution if possible
How much privilege do you have? If you have a directory with write access and basic build tools (automake), you can download the source tarball, install the catdoc to the local dir, and use it.

e.g.:
I have +wx access to ~/mystuff. Then:
Code:
wget http://fossies.org/unix/misc/old/catdoc-0.94.2.tar.gz
tar xvzf catdoc-0.94.2.tar.gz
cd catdoc-0.94.2
mkdir build && ./configure --disable-wordview --with-install-root=${PWD}/build
make && make install

Then create a file ~/.catdocrc and put some config paths in there:
Code:
cat >  ~/.catdocrc <<EOF
charset_path=${HOME}/mystuff/catdoc-0.94.2/build/usr/local/share/catdoc
map_path=${HOME}/mystuff/catdoc-0.94.2/build/usr/local/share/catdoc
source_charset=cp1252
target_charset=8859-1
unknown_char='?'
EOF

And you should be good to go:
Code:
~/mystuff/catdoc-0.94.2/build/usr/local/bin/xls2csv myfile.xls

This User Gave Thanks to mirni For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Merging Multiple XLS into Different tabs in xls/ xlsx

HI, I have multiple files per dept in folder for eg : In a folder File1_Dept100.xls File2_Dept100.xls File3_Dept100.xls File1_Dept200.xls File2_Dept200.xls File3_Dept200.xls Output should be : Dept100.xls which has File1, File2, File3 in different tabs Dept200.xls which has... (1 Reply)
Discussion started by: venkyzrocks
1 Replies

2. Emergency UNIX and Linux Support

Dealing with XLS file with multiple tabs

Hey Guys , Recently working on a requirement , i had to deal with XLS file with multiple tabs and the requirement was as below : 1. Convert one XLS file with multiple tabs to multiple CSV files. -- As i was working on MAC , so it was quite easy through APPLESCRIPT to deal with this.But... (6 Replies)
Discussion started by: himanshu sood
6 Replies

3. UNIX for Advanced & Expert Users

Shell script for dealing with XLS file with multiple tabs/worksheets

Hey Guys , Recently working on a requirement , i had to deal with XLS file with multiple tabs and the requirement was as below : 1. Convert one XLS file with multiple tabs to multiple CSV files. -- As i was working on MAC , so it was quite easy through APPLESCRIPT to deal with this.But... (2 Replies)
Discussion started by: himanshu sood
2 Replies

4. Shell Programming and Scripting

Script for converting to xls and to mail the same

i have installed CENTOS in VMware. I want the linux command to run in CENTOS. The command is to select data's from Event table(our table name) convert into .xls and mail every 2hrs. Can you please help me in writing this script. Thanks, Shobana (1 Reply)
Discussion started by: shobana praveen
1 Replies

5. Shell Programming and Scripting

Converting specific Excel file tabs to CSV in Python

Hi list, This is probably something really simple, but I am not particularly familiar with Python so I thought I would ask as I know that python has an excel module. I have an excel document with multiple tabs of data and graphs. One of the tabs is just data which I require to have dumped to... (8 Replies)
Discussion started by: landossa
8 Replies

6. Shell Programming and Scripting

Converting .xls into .csv and find & Replace

Hi All, Please give me the solution to the following ASAP. 1) Converting the .xls into .csv Script i tried, mv hello.xls hello.csv The above given script converting the .xls file into .csv successfully. But after i run the below unix command I am no able to open the .csv file, its giving... (4 Replies)
Discussion started by: velava
4 Replies

7. UNIX for Advanced & Expert Users

Converting .csv file into .xls file and send it to inbox

Hi All, I wrote a script to extract data from Oracle DB and place it in a text file , and I have coverted .txt file into comma seperated .csv file and I sent it to my mail box . I can get .xls file in my inbox.I am getting all data in same column and in different rows , without column... (1 Reply)
Discussion started by: krthkmuthu
1 Replies

8. Shell Programming and Scripting

converting xls file to txt file and xls to csv

I need to convert an excel file into a text file and an excel file into a CSV file.. any code to do that is appreciated thanks (6 Replies)
Discussion started by: bandar007
6 Replies

9. Shell Programming and Scripting

Converting csv to xls

Hi, Can anyone tell the option to change the file type in unix. i.e. if a file is in csv(Comma Separating Values) format, it should be changed to xls(ordinary MS-Excel) format. But renaming command is not changing to correct file format. Thanks in advance, Milton. (1 Reply)
Discussion started by: miltony
1 Replies

10. Shell Programming and Scripting

Converting tabs in to spaces.

Hi! I'm using SunOS 5.7 w/ Bash 2.01. Currently, I'm working on a script that will make it possible to find textfiles which match certain criteria. While I write this message, I had some brainfarts, found the answer myself :D and the question I had in mind is now no longer the question I... (3 Replies)
Discussion started by: indo1144
3 Replies
Login or Register to Ask a Question