rab777hp
rab777hp

Reputation: 33

How to write to a spreadsheet in python3.2?

I am currently writing a script where I want to take the data and write it to a spreadsheet. I've found a few modules for writing xls files, however those only seem to work up to python 2.x, and I'm using 3.2 (also on a mac if that's helpful). Anyone have any ideas on how to get a python3.2 script to output to a spreadsheet?

Upvotes: 2

Views: 1021

Answers (2)

Raymond Hettinger
Raymond Hettinger

Reputation: 226211

On Windows, you can use the COM interface: http://users.rcn.com/python/download/quoter.pyw

As @sdolan pointed out, CSV can be a good choice if your data is laid out in a tabular format.

Since Excel can save spreadsheets in an XML format, you can use XML tools to access the data.

Upvotes: 0

Sam Dolan
Sam Dolan

Reputation: 32532

Use the csv module. The intro from the docs:

The csv module implements classes to read and write tabular data in CSV format. It allows programmers to say, “write this data in the format preferred by Excel,” or “read data from this file which was generated by Excel,” without knowing the precise details of the CSV format used by Excel. Programmers can also describe the CSV formats understood by other applications or define their own special-purpose CSV formats.

Upvotes: 2

Related Questions