Fix the error of output, a new copies of data has been upload

This commit is contained in:
Chenxiao Xia 2023-11-01 10:28:08 +08:00
parent e07617bebc
commit 24aa62c8db
2 changed files with 25 additions and 19 deletions

View File

@ -90,18 +90,22 @@ def arDataTransform(au_folder, ar_dataset, num):
# Store into the new file
filepaths = [
"./EJQTDE_buffer_transform/Article_output/EJQTDE_Article_output_file(oldest).json",
"./EJQTDE_buffer_transform/Article_output/EJQTDE_Article_output_file(2010-2014).json",
"./EJQTDE_buffer_transform/Article_output/EJQTDE_Article_output_file(2015-2020).json",
"./EJQTDE_buffer_transform/Article_output/EJQTDE_Article_output_file(newest).json",
"./EJQTDE_buffer_transform/Article_output/EJQTDE_Article_output_file(oldest).json",
]
for filepath in filepaths:
for list in ar_dataset_new:
with open(filepath, "w", encoding='utf-8') as json_file:
json.dump(list, json_file, indent=4)
# for filepath in filepaths:
# for list in ar_dataset_new:
# with open(filepath, "w", encoding='utf-8') as json_file:
# json.dump(list, json_file, indent=4)
#
# break
break
for i in range(4):
with open(filepaths[i], 'w', encoding='utf-8') as json_file:
json.dump(ar_dataset_new[i], json_file, indent=4)
print("\nComplete: All of the article data structure have been transformed.")
@ -135,27 +139,28 @@ def auDataTransform(au_dataset, num):
return new_list
# Transform the author data structure
au_dataset_new = [] # New list to store transformed data
# # Transform the author data structure
# au_dataset_new = [] # New list to store transformed data
for au_list in au_dataset:
au_list_new = transform(au_list, num)
au_dataset_new.append(au_list_new)
# for au_list in au_dataset:
# au_list_new = transform(au_list, num)
# au_dataset_new.append(au_list_new)
for i in range(4):
au_list = transform(au_dataset[i], num)
au_dataset_new[i].append(au_list)
# Store into the new file
filepaths = [
"./EJQTDE_buffer_transform/Author_output/EJQTDE_Author_output_file(oldest).json",
"./EJQTDE_buffer_transform/Author_output/EJQTDE_Author_output_file(2010-2014).json",
"./EJQTDE_buffer_transform/Author_output/EJQTDE_Author_output_file(2015-2020).json",
"./EJQTDE_buffer_transform/Author_output/EJQTDE_Author_output_file(newest).json",
"./EJQTDE_buffer_transform/Author_output/EJQTDE_Author_output_file(oldest).json",
]
for filepath in filepaths:
for list in au_dataset_new:
with open(filepath, "w", encoding='utf-8') as json_file:
json.dump(list, json_file, indent=4)
break
for i in range(4):
with open(filepaths[i], 'w', encoding='utf-8') as json_file:
json.dump(au_dataset_new[i], json_file, indent=4)
print("\nComplete: All of the author data structure have been transformed.")
@ -166,6 +171,7 @@ ar_dataset = []
au_dataset = []
ar_dataset_new = [[] for _ in range(4)] # New list for transformed data
au_dataset_new = [[] for _ in range(4)] # New list to store transformed data
num1 = [0] # Counter for complete ar_date
num2 = [0] # Counter for complete au_data
@ -179,4 +185,4 @@ au_dataset = fileReader('./EJQTDE_buffer/Author_output', au_dataset)
# Change the structure
arDataTransform('./EJQTDE_buffer/Author_output', ar_dataset, num1)
auDataTransform(au_dataset, num2)
# auDataTransform(au_dataset, num2)