Open Office and Python
Ben Sizer
kylotan at gmail.com
Fri Aug 25 09:32:22 EDT 2006
F wrote:
> I'd like to load a .csv file to the Open Office spreadsheet from the command
> line using an arbitrary delimiter through Python. I don't need any fancy
> formatting and stuff like that, just putting the values in the spreadsheet
> will do.
>
> Is there a relatively simple way to do that?
I assume when you say load you mean create. To 'load' usually means to
read data rather than write it. If you want to read the data in, then a
Google search for "python csv" should answer all your questions.
Otherwise...
How are the values stored? It might be as simple as this:
# sample data
table = [
("item1", 10, 100),
("item 2", 15, 300)
]
out = file("my.csv", "w+")
for row in table:
out.write(",".join(str(item) for item in row) + "\n")
And my.csv will look like:
item1,10,100
item 2,15,300
--
Ben Sizer
More information about the Python-list
mailing list