Created
September 20, 2013 16:05
-
-
Save marcelnicolay/6639871 to your computer and use it in GitHub Desktop.
Kanbanery resource parse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
import json | |
from datetime import datetime | |
from operator import itemgetter | |
import codecs | |
tasks = [] | |
with open('arquived.json', 'r') as f: | |
tasks.extend(json.load(f)) | |
with open('tasks.json', 'r') as f: | |
tasks.extend(json.load(f)) | |
with open('columns.json', 'r') as f: | |
columns = {c['id']:c for c in json.load(f)} | |
ordered_tasks = sorted(tasks, key=itemgetter('moved_at')) | |
head = u'Título, Criação, Atualização, Status, Referência\n' | |
message = u'"{title}", "{created_at}", "{moved_at}", "{column_name}", "{id}"\n' | |
outputFile = codecs.open("historias_output.csv", "w", "UTF-8") | |
outputFile.write(head) | |
for i, task in enumerate(ordered_tasks): | |
column = columns.get(task['column_id']) | |
task['column_name'] = column['name'] if column else None | |
task['created_at'] = datetime.strptime(task['created_at'], | |
'%Y-%m-%dT%H:%M:%S+00:00').strftime('%Y-%m-%d') | |
task['moved_at'] = datetime.strptime(task['moved_at'], | |
'%Y-%m-%dT%H:%M:%S+00:00').strftime('%Y-%m-%d') | |
task['count'] = i + 1 | |
task['title'] = task['title'].replace('\"', "'") | |
task['description'] = task['description'].replace('\"', "'") | |
outputFile.write(message.format(**task)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment