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 csv
|
||||||
import json
|
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):
|
def extract_unique_names_and_ids(data):
|
||||||
@ -10,18 +16,18 @@ def extract_unique_names_and_ids(data):
|
|||||||
unique_names = set()
|
unique_names = set()
|
||||||
unique_ids = set()
|
unique_ids = set()
|
||||||
|
|
||||||
for item in data:
|
for item in data["data"]:
|
||||||
assignee = item.get("assignee")
|
assignee = item["assignee"]
|
||||||
followers = item.get("followers")
|
followers = item["followers"]
|
||||||
|
|
||||||
if assignee:
|
if assignee:
|
||||||
unique_names.add(assignee.get("name"))
|
unique_names.add(assignee["name"])
|
||||||
unique_ids.add(assignee.get("id"))
|
unique_ids.add(assignee["gid"])
|
||||||
|
|
||||||
if followers:
|
if followers:
|
||||||
for follower in followers:
|
for follower in followers:
|
||||||
unique_names.add(follower.get("name"))
|
unique_names.add(follower["name"])
|
||||||
unique_ids.add(follower.get("id"))
|
unique_ids.add(follower["gid"])
|
||||||
|
|
||||||
return unique_names, unique_ids
|
return unique_names, unique_ids
|
||||||
|
|
||||||
@ -35,8 +41,8 @@ def export_to_csv(unique_names, unique_ids):
|
|||||||
writer.writerow([name, id])
|
writer.writerow([name, id])
|
||||||
|
|
||||||
|
|
||||||
with open('asana_data', 'r') as file:
|
file = open(asana_data_json, "r", encoding="utf8")
|
||||||
json_data = json.load(file)
|
json_data = json.loads(file.read())
|
||||||
|
|
||||||
unique_names, unique_ids = extract_unique_names_and_ids(json_data)
|
unique_names, unique_ids = extract_unique_names_and_ids(json_data)
|
||||||
export_to_csv(unique_names, unique_ids)
|
export_to_csv(unique_names, unique_ids)
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import json
|
import json
|
||||||
|
import os
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from yandex_tracker_client import TrackerClient
|
from yandex_tracker_client import TrackerClient
|
||||||
@ -13,7 +14,8 @@ YANDEX_TRACKER_TOKEN = 'y0_AgAEA7qkfTFqAArTqQAAAADyduv806rRKh8MS6GOg01ZdwPE-F4ZH
|
|||||||
ORG_ID = '35d164dcf81e48f2b6a532f4badddd33'
|
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():
|
def main():
|
||||||
""" Основная функция для переноса данных """
|
""" Основная функция для переноса данных """
|
||||||
# asana_data = get_data_from_asana()
|
# 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)
|
asana_data = json.load(file)
|
||||||
# return asana_data
|
# return asana_data
|
||||||
yandex_tracker_data = transform_data(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