Mapping_ya_tracker/asana_users.py

38 lines
905 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import json
import csv
DATA_ASANA = './data/data_asana.json'
def get_assignee_and_followers(asana_data):
""" Получение из json-файла данных о пользователях """
with open('asana_data', 'r') as file:
data = json.load(file)
assignees = set()
followers = set()
for item in data:
assignee = item.get('assignee')
follower = item.get('followers')
if assignee:
assignees.add(assignee)
if follower:
followers.add(follower)
with open('output.csv', 'w', newline='') as file:
writer = csv.writer(file, delimiter=',')
writer.writerow(["Assignee", "Follower"])
for assignee in assignees:
writer.writerow([assignee, ""])
for follower in followers:
writer.writerow(["", follower])
get_assignee_and_followers(DATA_ASANA)