fix(users): performing skript for create file.csv, create file.csv
This commit is contained in:
parent
dfde2b8f0a
commit
05d361264c
@ -1,7 +1,13 @@
|
||||
import csv
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
asana_data = './data/data_asana.json'
|
||||
|
||||
base_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
asana_data_json = os.path.join(base_dir, './data/data_asana.json')
|
||||
|
||||
sys.stdout.reconfigure(encoding='utf-8')
|
||||
|
||||
|
||||
def extract_unique_names_and_ids(data):
|
||||
@ -10,18 +16,18 @@ def extract_unique_names_and_ids(data):
|
||||
unique_names = set()
|
||||
unique_ids = set()
|
||||
|
||||
for item in data:
|
||||
assignee = item.get("assignee")
|
||||
followers = item.get("followers")
|
||||
for item in data["data"]:
|
||||
assignee = item["assignee"]
|
||||
followers = item["followers"]
|
||||
|
||||
if assignee:
|
||||
unique_names.add(assignee.get("name"))
|
||||
unique_ids.add(assignee.get("id"))
|
||||
unique_names.add(assignee["name"])
|
||||
unique_ids.add(assignee["gid"])
|
||||
|
||||
if followers:
|
||||
for follower in followers:
|
||||
unique_names.add(follower.get("name"))
|
||||
unique_ids.add(follower.get("id"))
|
||||
unique_names.add(follower["name"])
|
||||
unique_ids.add(follower["gid"])
|
||||
|
||||
return unique_names, unique_ids
|
||||
|
||||
@ -35,8 +41,8 @@ def export_to_csv(unique_names, unique_ids):
|
||||
writer.writerow([name, id])
|
||||
|
||||
|
||||
with open('asana_data', 'r') as file:
|
||||
json_data = json.load(file)
|
||||
file = open(asana_data_json, "r", encoding="utf8")
|
||||
json_data = json.loads(file.read())
|
||||
|
||||
unique_names, unique_ids = extract_unique_names_and_ids(json_data)
|
||||
export_to_csv(unique_names, unique_ids)
|
||||
|
@ -1,4 +1,5 @@
|
||||
import json
|
||||
import os
|
||||
|
||||
import requests
|
||||
from yandex_tracker_client import TrackerClient
|
||||
@ -13,7 +14,8 @@ YANDEX_TRACKER_TOKEN = 'y0_AgAEA7qkfTFqAArTqQAAAADyduv806rRKh8MS6GOg01ZdwPE-F4ZH
|
||||
ORG_ID = '35d164dcf81e48f2b6a532f4badddd33'
|
||||
|
||||
|
||||
asana_data_json = './data/data_asana.json'
|
||||
base_dir = os.path.dirname(os.path.realpath(__file__))
|
||||
asana_data_json = os.path.join(base_dir, './data/data_asana.json')
|
||||
|
||||
|
||||
# ниже функция для случаев, когда не будет готового файла для импорта
|
||||
@ -85,7 +87,7 @@ def create_tasks_in_tracker(data):
|
||||
def main():
|
||||
""" Основная функция для переноса данных """
|
||||
# asana_data = get_data_from_asana()
|
||||
with open('asana_data_json', 'r') as file:
|
||||
with open(asana_data_json, 'r') as file:
|
||||
asana_data = json.load(file)
|
||||
# return asana_data
|
||||
yandex_tracker_data = transform_data(asana_data)
|
||||
|
9
output.csv
Normal file
9
output.csv
Normal file
@ -0,0 +1,9 @@
|
||||
Name,ID
|
||||
Cyrill Gafarov,2495641457856
|
||||
Сергей Анисов,1203071663735925
|
||||
Илья,698025068994499
|
||||
IrinaOs,2495641457848
|
||||
Никита,1204278463134045
|
||||
Malkova,2934206415688
|
||||
Sergey Volodin,547756841476
|
||||
Diza,1202859655765863
|
|
Loading…
Reference in New Issue
Block a user