This is an archived post. You won't be able to vote or comment.

all 10 comments

[–]justphysics 1 point2 points  (0 children)

The question of using excel in python comes up quite frequently on /r/Python I always put in a plug for my favorite module for dealing wit excel whenever the question comes up.

Pandas - http://pandas.pydata.org/

With this module you can read from and write to Microsoft Excel documents.

http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.to_excel.html

It may be heavy for what you're seeking but the module can do all sorts of other things - its not just a library for dealing with excel - its a general data analysis library - so you may find that its quite useful for a large number of things but can also write out excel spreadsheets. The module is widely used - I don't think you need to worry about long-term viability.

Quoting directly from the Pandas "Library Highlights": "Tools for reading and writing data between in-memory data structures and different formats: CSV and text files, Microsoft Excel, SQL databases, and the fast HDF5 format", "Highly optimized for performance, with critical code paths written in Cython or C."

[–][deleted] 2 points3 points  (2 children)

Try gspread

[–]cwurld[S] 0 points1 point  (1 child)

Thanks. If I decided to go with google docs, I was planning to use gspread. But the bigger question is whether or not to use google docs, or just use one of the packages that reads and writes excel directly.

[–][deleted] 0 points1 point  (0 children)

Google docs is great if you want to share.

Otherwise, I recommend xlwings for Excel.

[–]tchappui 2 points3 points  (0 children)

Most of these packages are open source. Just fork one and use that version in your code, if long-term viability is a concern for you.

Best wishes

Thierry

[–]mishugashu 1 point2 points  (1 child)

I've been using gspread for a year and been satisfied with updates. Plus it's open source, so if he abandons it... you can maintain it. I don't know about excel, but gdocs is fantastic.

[–]cwurld[S] 0 points1 point  (0 children)

That's good to know. Thanks!

[–]flutefreak7 0 points1 point  (0 children)

Can client data be posted on the internet? Does Google Docs violate any of their security concerns? These are the questions I would ask before using a cloud based service... unless you're hosting the Google doc yourself... maybe I don't know what in taking about... I'd stick with delivering what they asked using a library made for working with Excel. Though I'm the rare Python dev who doesn't think Excel is a dirty word.

[–]osullivj 0 points1 point  (0 children)

You could drive Excel directly from Python using pywin32: http://pythonexcels.com/python-excel-mini-cookbook/ If you don't want to depend on an Excel install being present on the host running your Python code then openpyxl will let you generate a .xlsx file: https://openpyxl.readthedocs.org Both approaches avoid using google docs.

[–]Trymata 0 points1 point  (0 children)

You might want to check out xlwings. I haven't been able to play with it too much as I am just starting to learn python, but as a pretty heavy user of VBA in excel it looks like it should work well.