The fastest way to convert a long list of date

loredana.pier at gmail.com loredana.pier at gmail.com
Sun Feb 8 11:30:06 EST 2009


First of all: Thanks for your reply
My use case is the following:
I perform a query to DB and the result of query is this;

>>> print rows
{‘Label’: {'2009:01:30': 9, '2009:01:28': 13, '2009:01:29': 19,
'2009:01:26': 1, '2009:01:27': 3, '2009:01:20': 86, '2009:01:22': 3,
'2009:01:23': 12, '2009:02:07': 3, '2009:02:06': 12, '2009:02:05': 15,
'2009:02:04': 12, '2009:02:02': 2}}

I want to make a chart with this data using JSON format where:
•	the key ‘Label’ is the title of chart,
•	rows['Label'].keys() is x values,
•	rows[‘Label’].values() is the y values

So my goal is:

1)	to fill the bin of chart with no data (for example  in this tupla..
[.., '2009:01:28: 9, '2009:01:30: 13,..].. the date '2009:01:29’ is
missing and I want to append the value ['2009:01:29’,0] to rows
[‘Label’])

2)	convert the date format (for example in '%A %d, %b %y')

3)	transform rows dictionary in JSON code

The point 3) is easy to implement but I’m wondering which is the best
way to implement the point 1) and 2) ...considering it will be used
for a web application (CherryPy)?

thanks,

Loredana



More information about the Python-list mailing list