Hi,
How to write below data to csv in below output format ?
list of dict
data=[{'date': datetime.date(2011, 2, 8), 'user': u'xxx', 'status':
u'P'}, {'date': datetime.date(2011, 2, 8), 'user': u'yyy', 'status': u'P'},
{'date': datetime.date(2011, 2, 8), 'user': u'zzz', 'status': u'P'},
{'date': datetime.date(2011, 2, 9), 'user': u'xxx, 'status': u'P'}, {'date':
datetime.date(2011, 2, 9), 'user': u'yyy', 'status': u'E'}, {'date':
datetime.date(2011, 2, 9), 'user': u'zzz', 'status': u'E'}, {'date':
datetime.date(2011, 2, 10), 'user': u'xxx', 'status': u'P'}, {'date':
datetime.date(2011, 2, 10), 'user': u'yyy', 'status': u'P'}, {'date':
datetime.date(2011, 2, 10), 'user': u'zzz', 'status': u'P'}]
Output format should be :
S.no user 2011-02-08 2011-02-09 2011-02-10 p-total E-total total
1 xxx p p p 3 0 3
2 yyy p E p 2 1 3
3 zzz p E E 1 2 3
code :
import csv
from datetime import datetime,date
d=28
for i in xrange(1,d):
date_format = now.replace( year = 2011 , month = 02 , day = i )
writer = csv.DictWriter(f, ['S.no', 'user',
'date_format','p-total','E-total','Total'])
how to write to items to csv ?
Please need help
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.