user3398898
user3398898

Reputation: 11

To split multiple sheets in an excel to multiple csv files

I have a single Excel containing many sheets as sheet1, sheet2, sheet3, etc. I need to split this Excel into individual CSVs, i.e.

sheet1--->file1.csv

sheet2-->file2.csv

sheet3-->file3.csv

and so on...

I need to do this either using PERL or UNIX. I also want to know the record count from each of the individually generated CSVs.

Since I am a beginner in Unix, I spent much time in writing the code and it doesn't seem working.
Please give your suggestions. Thanks in advance.

Upvotes: 1

Views: 4356

Answers (2)

Cyril Chaboisseau
Cyril Chaboisseau

Reputation: 479

You can either use the csvkit program:

in2csv --write-sheets "-" -f Masterfile.xlsx

which will generate as many files as they are sheets

Masterfile_0.csv Masterfile_1.csv ...

or you can also use the ssconvert tool from the Gnumeric project:

ssconvert -S Masterfile.xlsx split_file.csv

but the naming scheme is less convenient as each file have the sheet number prepended (they need to be renamed):

split_file.csv.0 split_file.csv.1

Upvotes: 1

Rakshit Singh
Rakshit Singh

Reputation: 169

I was facing the same issue, I guess this post (link) should help you.Batch split xls sheets to csv - This contains a js code which you just have to put inside the folder where you have all the xls files.It will split the sheets into separate csv and name them following this syntax: {file_name}-{worksheet_name}.csv Hope this helps.

Upvotes: 0

Related Questions