GNOME Bugzilla – Bug 549604
Export report to csv / spreadsheet
Last modified: 2009-06-07 11:28:54 UTC
I enter my time from Hamster into a time-tracking spreadsheet. CSV export would be a great time-saver and would make filtration / formatting much easier...
Created attachment 117519 [details] [review] CSV report added Hi Ben, Actually I was working on it, because I need it as well for the work. But I was trying to approach this not just as a another specific export thing, but as a more general way to show the stats. In that way I was working on bug #531342. But all this will be on the next release, now we are on GNOME release process, so we can't ship out any change on the main version. Anyway, for the meantime I attach a simple change to export a CSV report. It just adds a button on the stats dialog for it and export a simple csv report, just as the HTML one does. I hope this help a bit by now.
Thanks Juanje! I appreciate the help!
*** Bug 531342 has been marked as a duplicate of this bug. ***
*** Bug 580661 has been marked as a duplicate of this bug. ***
Rudimentary XML export as well as TSV (tab separated values) is now in git master branch. Went with TSV because that should be a weeny bit safer than CSV in parsing (commas ar common for descriptions, but not tabs - didn't want to bother with escapes there). Export is accessible via the save button in overview. So, errrm, hooray and such.
Uhm, couldn't you just "import csv" and use csv.writer to do all the job?
hahah,i had no idea that there is such thing! thanks for checking out the commit, fixed now!
One more thing, you need to wrap writer.writerow in a small function that does .encode('utf-8') on all unicode objects before passing them. Something like: def csv_prefilter(data): for row in data: ret = [] for field in row: if type(field) is unicode: result = field.encode('utf-8') elif field is None: result = '' else: result = str(field) ret.append(result) yield ret That's because python csv module can't handle unicode yet (see "Note" at http://docs.python.org/library/csv.html).
Although it seems to work fine with unicode chars even without encode, i added it to name, category and description. Also turned the whole thing somewhat more class oriented and added a lame iCal export. There will be bugs (well, maybe, naturally) :)