38 lines
905 B
Python
38 lines
905 B
Python
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)
|