Skip to content

Commit f4fa6ea

Browse files
authored
chore: add progress bar to journal data update script (#2182)
1 parent 900ef4a commit f4fa6ea

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

scripts/journaldata.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
from prisma import Prisma
3535
from prisma.types import JournalCitationInfoYearlyCreateWithoutRelationsInput
36+
from tqdm import tqdm
3637

3738
# current_year should be the latest year of data available at https://www.scimagojr.com/journalrank.php
3839
current_year = 2022
@@ -137,8 +138,7 @@ def download_all_data():
137138
def combine_data():
138139
"""Iterate over files and return the consolidated dataset"""
139140
journals: dict[int, JournalInfo] = {}
140-
for year in range(start_year, current_year + 1):
141-
print(f'Processing {year}')
141+
for year in tqdm(range(start_year, current_year + 1), desc='Processing data'):
142142
filepath = get_data_filepath(year)
143143
with open(filepath, mode='r', encoding='utf-8') as csv_file:
144144
csv_reader = csv.DictReader(csv_file, delimiter=';')
@@ -212,7 +212,7 @@ async def dump_into_database(journals: dict[int, JournalInfo]):
212212
# delete all existing yearly data (because its easier than updating)
213213
await db.journalcitationinfoyearly.delete_many()
214214

215-
for journal in journals.values():
215+
for journal in tqdm(journals.values(), desc='Saving to database'):
216216
citation_info: list[JournalCitationInfoYearlyCreateWithoutRelationsInput] = [
217217
{
218218
'year': year,

0 commit comments

Comments
 (0)