Closed GoogleCodeExporter closed 9 years ago
After playing some more with the code, I found out how to export
spreadsheet-friendly dates. You need to supply formatted values, besides the
raw values:
import datetime
import gviz_api
data = []
row = {}
row['date'] = (datetime.date(2011,1,1), '2011-01-01')
row['icecreams'] = 1
data.append(row)
row = {}
row['date'] = (datetime.date(2011,1,2), '2011-01-02')
row['icecreams'] = 2
data.append(row)
description = {}
description["date"] = ("date", "Date")
description["icecreams"] = ("number", "Ice creams eaten")
data_table = gviz_api.DataTable(description)
data_table.LoadData(data)
print data_table.ToCsv()
Result:
"Date", "Ice creams eaten"
"2011-01-01", 1
"2011-01-02", 2
It's still a little odd that the ToCsv() method by default returns a hybrid
Javascript/spreadsheet format that can be used neither by Javascript nor
spreadsheets. But there is a way around it.
Given the workaround, I will let the project maintainers decide if this bug
should be discarded or assigned a low priority.
Cheers,
/Martin
Original comment by momander@google.com
on 30 Aug 2011 at 8:38
Fixed in version 1.8.0
Original comment by jbas...@google.com
on 27 Jan 2012 at 8:50
Thanks for fixing it! The fix will make life easier for the developers who are
just getting started with the library.
Original comment by momander@google.com
on 30 Jan 2012 at 3:58
Original issue reported on code.google.com by
momander@google.com
on 30 Aug 2011 at 8:19