Skip to content

Instantly share code, notes, and snippets.

@tonigi
Last active July 2, 2020 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tonigi/a0158ac592ae102a32bfccd3b3f8e9a5 to your computer and use it in GitHub Desktop.
Save tonigi/a0158ac592ae102a32bfccd3b3f8e9a5 to your computer and use it in GitHub Desktop.
Parse NLM Catalog journal list
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