【发布时间】:2019-06-01 11:12:09
【问题描述】:
我需要将我工作区的特定项目中的所有 Asana 任务导出到 csv 文件。我一直通过 Asana 的高级搜索手动执行此操作,但 Asana 生成的 csv 文件仅支持
import sys
import csv
import asana
def process_project_tasks(client, project, ws_dict):
"""Add each task for the current project to the records list."""
task_list = []
while True:
tasks = client.tasks.find_by_project(project['id']
{"opt_fields":"name, projects, workspace, id, due_on, created_at,
modified_at, completed, completed_at, assignee, assignee_status, parent,
notes"})
for task in tasks:
ws_name = ws_dict[task['workspace']['id']]
assignee = task['assignee']['id'] if task['assignee'] is not
None else ''
created_at = task['created_at'][0:10] + ' ' +
task['created_at'][11:16] if \
task['created_at'] is not None else None
modified_at = task['modified_at'][0:10] + ' ' +
task['modified_at'][11:16] if \
task['modified_at'] is not None else None
completed_at = task['completed_at'][0:10] + ' ' +
task['completed_at'][11:16] if \
task['completed_at'] is not None else None
rec = [task['name'], project['name'], ws_name,task['due_on'],
created_at, \
modified_at, task['completed'], completed_at, assignee, \
task['assignee_status'], task['parent'], task['notes'],
task['id']]
rec = ['' if s is None else s for s in rec]
task_list.append(rec)
if 'next_page' not in tasks:
break
return task_list
【问题讨论】:
标签: python python-3.x pypi asana asana-api