Using Python to Automate Creation/Manipulation of Excel Spreadsheets

Tags: python excel
By : Tim
Source: Stackoverflow.com
Question!

I have some data in CSV format that I want to pull into an Excel spreadsheet and then create some standard set of graphs for. Since the data is originally generated in a Python app, I was hoping to simply extend the app so that it could do all the post processing and I wouldn't have to do it by hand. Is there an easy interface with Python to work with and manipulate Excel spreadsheets? Any good samples of doing this? Is this Windows only (I'm primarily working on a Mac and have Excel, but could do this on Windows if necessary).

By : Tim


Answers
xlutils (and the included packages xlrd and xlwt) should allow your Python program to handily do any creation, reading and manipulation of Excel files you might want!



On Windows you could use the pywin32 package to create an Excel COM Object and then manipulate it from a script. You need to have an installed Excel on that machine though. I haven't done this myself so I can't give you and details but I've seen this working so can at least confirm that it's possible. No idea about OS X, unfortunately.



This video can help you solving your question :)
By: admin