0

In excel I can open up a csv file using external data sources, and then chose to get data from text. This takes me through a set of steps to import the file. This works great, but I have a need to automate this process as many of these documents will need to be converted over time.

Is there a way to run a similar process as a script? I'm a complete newbie in this space.

d90
  • 767
  • 2
  • 10
  • 28
  • possible duplicate of [converting an Excel (xls) file to a comma separated (csv) file without the GUI](http://stackoverflow.com/questions/943153/converting-an-excel-xls-file-to-a-comma-separated-csv-file-without-the-gui) – Sunny Patel Mar 27 '14 at 19:16
  • That is converting excel to csv. I need to convert csv to excel. – d90 Mar 27 '14 at 20:16
  • My mistake. I rushed the process. Try http://stackoverflow.com/questions/8701044/import-csv-to-excel-automatically-text-to-columns-and-insert-table – Sunny Patel Mar 27 '14 at 20:19

1 Answers1

0

You can run this command in a script:

csv2odf yourdata.csv yourtemplate.xlsx output.xlsx

You would need to get csv2odf and Python and create a template like this:

  1. Insert column titles with the same number of columns as the csv.
  2. Add one sample row of data. You can add formatting if you want.
  3. Save the template as xlsx.
Larry1833681
  • 186
  • 4
  • This doesn't seem to work for larger files. I tried a few tests limiting the processed rows to lower numbers like 50 and it does the work perfect. The problem is the files I need to convert are between 250k-400k lines and I run out of memory before it can finish. – d90 Apr 10 '14 at 13:27
  • Version 2 of csv2odf is out, it handles large files better. I tested it with 1 million lines on a computer with only 1G of ram. – Larry1833681 Sep 21 '14 at 01:06