text_html_output_1.png
from pprint import pprint

from time import time

import pandas as pd

pd.read_csv('/kaggle/input/CORD-19-research-challenge/metadata.csv', nrows=3)

meta_by_sha = {}
meta_by_pmc = {}
t0 = time()
COLS = ['cord_uid', 'sha', 'pmcid', 'publish_time', 'journal', 'url', 'title', 'authors']
df = pd.read_csv('/kaggle/input/CORD-19-research-challenge/metadata.csv')
selected = df[df['full_text_file'] != ''][COLS]
rows = selected.iterrows()
for _, r in rows:
    if type(r['sha']) is str:
        for sha in r['sha'].split(';'):
            sha = sha.strip()
            meta = {k: r[k] for k in COLS}
            meta_by_sha[sha] = meta
    if type(r['pmcid']) is str:
        pmc = r['pmcid']
        meta = {k: r[k] for k in COLS}
        meta_by_pmc[pmc] = meta

print('Paper metadata sample:\n')
for sha in meta_by_sha:
    pprint(meta_by_sha[sha])
    break