Add code for saving data
This commit is contained in:
parent
9ee9bc4462
commit
a9c753567c
@ -1,5 +1,7 @@
|
||||
import json
|
||||
import os
|
||||
from pprint import pprint
|
||||
|
||||
import unicodedata
|
||||
|
||||
'''
|
||||
@ -63,6 +65,8 @@ def SameWeb_merge(folder_path):
|
||||
|
||||
# Update the counter
|
||||
count[0] += 1
|
||||
if count[0] % 100 == 0 and count[0] != 0:
|
||||
print(str(count[0]) + ' copies of data have been merged.')
|
||||
return Merge(a, count, Data)
|
||||
|
||||
# ========== Main code ==========
|
||||
@ -86,13 +90,26 @@ def SameWeb_merge(folder_path):
|
||||
Merge(a, count, Data)
|
||||
|
||||
# Information
|
||||
print(str(count[0]) + ' copies of data have been merged.')
|
||||
print('\n========== Complete ==========\n')
|
||||
print(str(Database) + ' copies of data in total, before')
|
||||
print(str(count[0]) + ' copies of data have been merged.')
|
||||
print(str(len(Data)) + ' copies of data in total, now.')
|
||||
|
||||
# Save into file
|
||||
path = os.path.dirname(folder_path)
|
||||
path = os.path.join(path, "Author_data(merged)")
|
||||
os.makedirs(path, exist_ok=True)
|
||||
path = os.path.join(path, "Author_data(merged).json")
|
||||
|
||||
with open(path, 'w', encoding='utf-8') as file:
|
||||
json.dump(Data, file, indent=4)
|
||||
|
||||
print('\nData has been added to ' + path + '\Author_data(merged).json')
|
||||
|
||||
|
||||
# =========== input the file path here ==========
|
||||
# SameWeb_merge('./EJQTDE_buffer/Author_output')
|
||||
# SameWeb_merge('.\EJQTDE\EJQTDE_buffer\Author_output')
|
||||
# SameWeb_merge('.\SpringerOpen\SpringerOpen_buffer\Author_output')
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user