Update new save code

This commit is contained in:
Chenxiao Xia 2023-09-12 09:05:55 +08:00
parent c75d2545d7
commit d374a3766b
3 changed files with 13 additions and 26 deletions

View File

@ -30,24 +30,19 @@ def Transf():
file_path = os.path.join(folder_path, filename) file_path = os.path.join(folder_path, filename)
with open(file_path, 'r', encoding='utf-8') as file: with open(file_path, 'r', encoding='utf-8') as file:
data = json.load(file) data = json.load(file)
for Dict in data: for Dict in data:
if Dict.get('volume') is not None or Dict.get('affiliation', [{}])[0].get('year', 0) is not None: if Dict.get('volume') is not None or Dict.get('affiliation', [{}])[0].get('year', 0) is not None:
# Select data # Select data
if (isinstance(Dict, dict) and int( if int(Dict.get('volume') or Dict.get('affiliation', [{}])[0].get('year', 0)) <= 2009:
Dict.get('volume') or Dict.get('affiliation', [{}])[0].get('year', 0)) <= 2009):
data_oldest.append(Dict) data_oldest.append(Dict)
if (isinstance(Dict, dict) and 2010 <= int( elif int(Dict.get('volume') or Dict.get('affiliation', [{}])[0].get('year', 0)) <= 2014:
Dict.get('volume') or Dict.get('affiliation', [{}])[0].get('year', 0)) <= 2014):
data_2010_2014.append(Dict) data_2010_2014.append(Dict)
if (isinstance(Dict, dict) and 2015 <= int( elif int(Dict.get('volume') or Dict.get('affiliation', [{}])[0].get('year', 0)) <= 2020:
Dict.get('volume') or Dict.get('affiliation', [{}])[0].get('year', 0)) <= 2020):
data_2015_2020.append(Dict) data_2015_2020.append(Dict)
if (isinstance(Dict, dict) and int( else:
Dict.get('volume') or Dict.get('affiliation', [{}])[0].get('year', 0)) >= 2021):
data_newest.append(Dict) data_newest.append(Dict)
# Transfer # Transfer

View File

@ -36,20 +36,16 @@ def Transf():
for Dict in data: for Dict in data:
if Dict.get('volume') is not None or Dict.get('affiliation', [{}])[0].get('year', 0) is not None: if Dict.get('volume') is not None or Dict.get('affiliation', [{}])[0].get('year', 0) is not None:
# Select data # Select data
if (isinstance(Dict, dict) and int( if int(Dict.get('volume') or Dict.get('affiliation', [{}])[0].get('year', 0)) <= 2009:
Dict.get('volume') or Dict.get('affiliation', [{}])[0].get('year', 0)) <= 2009):
data_oldest.append(Dict) data_oldest.append(Dict)
if (isinstance(Dict, dict) and 2010 <= int( elif int(Dict.get('volume') or Dict.get('affiliation', [{}])[0].get('year', 0)) <= 2014:
Dict.get('volume') or Dict.get('affiliation', [{}])[0].get('year', 0)) <= 2014):
data_2010_2014.append(Dict) data_2010_2014.append(Dict)
if (isinstance(Dict, dict) and 2015 <= int( elif int(Dict.get('volume') or Dict.get('affiliation', [{}])[0].get('year', 0)) <= 2020:
Dict.get('volume') or Dict.get('affiliation', [{}])[0].get('year', 0)) <= 2020):
data_2015_2020.append(Dict) data_2015_2020.append(Dict)
if (isinstance(Dict, dict) and int( else:
Dict.get('volume') or Dict.get('affiliation', [{}])[0].get('year', 0)) >= 2021):
data_newest.append(Dict) data_newest.append(Dict)
# Transfer # Transfer

View File

@ -33,21 +33,17 @@ def Transf():
for Dict in data: for Dict in data:
if Dict.get('volume') is not None or Dict.get('affiliation', [{}])[0].get('year', 0) is not None: if Dict.get('volume') is not None or Dict.get('affiliation', [{}])[0].get('year', 0) is not None:
# 筛选文章 # Select data
if (isinstance(Dict, dict) and int( if int(Dict.get('volume') or Dict.get('affiliation', [{}])[0].get('year', 0)) <= 2009:
Dict.get('volume') or Dict.get('affiliation', [{}])[0].get('year', 0)) <= 2009):
data_oldest.append(Dict) data_oldest.append(Dict)
if (isinstance(Dict, dict) and 2010 <= int( elif int(Dict.get('volume') or Dict.get('affiliation', [{}])[0].get('year', 0)) <= 2014:
Dict.get('volume') or Dict.get('affiliation', [{}])[0].get('year', 0)) <= 2014):
data_2010_2014.append(Dict) data_2010_2014.append(Dict)
if (isinstance(Dict, dict) and 2015 <= int( elif int(Dict.get('volume') or Dict.get('affiliation', [{}])[0].get('year', 0)) <= 2020:
Dict.get('volume') or Dict.get('affiliation', [{}])[0].get('year', 0)) <= 2020):
data_2015_2020.append(Dict) data_2015_2020.append(Dict)
if (isinstance(Dict, dict) and int( else:
Dict.get('volume') or Dict.get('affiliation', [{}])[0].get('year', 0)) >= 2021):
data_newest.append(Dict) data_newest.append(Dict)
# 转存 # 转存