Create ODS worksheets from CSV files
Asked Answered
K

1

5

I have a set of CSV files, which I need to convert to a single ODS (or even excel) spreadsheet with multiple tabbed worksheets. Currently I'm using the pyexcel library for python, but it's buggy and horribly slow.

Libreoffice has a nice file conversion utility, but I don't see any support for worksheet tabs. Is there a simple way to script this?

Kerwon answered 31/8, 2015 at 3:18 Comment(4)
So you want to use Calc to open (large number of?) files, then copy the Sheet1 of all the files into one main file?Sedillo
I want some way to merge multiple CSV files into a single ODS file, with each CSV getting its own Sheet1, Sheet2, etc.Kerwon
how have you tried with pyexcel? what are the bugs you have seen? for tab separated csv file, pyexcel expects '*.tsv'.Teresa
Would a macro (in language of your choice) like this work: use Calc to open the CSV file with appropriate filter selections, rename tabs to something like "CSVfilename_Sheet1"; repeat for the next CSV file, copy all the sheets from the second file into the first one, close the second file without saving; repeat for all CSV files; save the first file? I wouldn't call it simple, I guess, but I'm not sure how else you'd automate this kind of thing.Sedillo
L
12

Came to this thread over 800 days since this question was asked, but I just got done doing the exact same thing and will post the process.

QUICK COMMAND FOR UBUNTU LINUX:

sudo apt-get install gnumeric ssconvert --merge-to=OUTPUT-FILE.xls *.csv

MORE DETAILS:

  1. Make sure you have access to a Linux or Mac computer.

  2. Install the gnumeric program. So sudo apt-get install gnumeric for Debian/Ubuntu, sudo dnf install gnumeric for RHEL, or brew install gnumeric for Mac.

  3. Run ssconvert --merge-to=OUTPUT-FILE.xls *.csv.

  4. *.csv will select every csv file in your current folder. You can also just enter multiple file names if you want as well.

  5. If you're running on Linux and have installed LibreOffice, you can open this file directly from the command line via libreoffice OUTPUT-FILE.xls
Leyte answered 9/2, 2018 at 20:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.