Skip to content

Instantly share code, notes, and snippets.

@sbassi
Created June 22, 2023 06:54
Show Gist options
  • Save sbassi/4f81867de1fcef2a6b305be38435ab32 to your computer and use it in GitHub Desktop.
Save sbassi/4f81867de1fcef2a6b305be38435ab32 to your computer and use it in GitHub Desktop.
"""
"""
ifile = '/Users/sb/projects/toyoko/abstracts.txt'
ofile = '/Users/sb/projects/toyoko/abstractsCLEAN.txt'
grab = True
ai = False
ci = False
cr = False
with open(ofile, "w") as fout:
# open a text file and read it
with open(ifile, "r") as f:
for line in f:
if line.startswith("DOI: "):
continue
elif line.startswith("PMID: "):
continue
elif line.startswith("PMCID: "):
continue
elif line.startswith("©"):
continue
if line.startswith("Conflict of interest statement:"):
ci = True
grab = False
if line.startswith("Author information:"):
ai = True
grab = False
if line.startswith("Copyright"):
cr = True
grab = False
if grab and not ai and not ci and not cr:
fout.write(line)
if ai and line=="\n":
grab = True
ai = False
if ci and line=="\n":
grab = True
ci = False
if cr and line=="\n":
grab = True
cr = False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment