Created
June 22, 2023 06:54
-
-
Save sbassi/4f81867de1fcef2a6b305be38435ab32 to your computer and use it in GitHub Desktop.
This file contains 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
""" | |
""" | |
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