Last active
July 2, 2020 22:46
-
-
Save tonigi/a0158ac592ae102a32bfccd3b3f8e9a5 to your computer and use it in GitHub Desktop.
Parse NLM Catalog journal list
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
dl = [] | |
d={} | |
with open("J_Medline.txt","r") as f: | |
for l in f: | |
l = l.strip() | |
if "----" in l: | |
dl.append(pd.Series(d)) | |
d={} | |
continue | |
ll = l.split(":",maxsplit=1) | |
if len(ll)==1: | |
ll.append("") | |
d[ll[0]]=ll[1].lstrip(" ") | |
df = pd.DataFrame(dl) | |
df.to_csv("J_Medline.csv") | |
df.to_excel("J_Medline.xlsx") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment