Skip to content

Instantly share code, notes, and snippets.

@arthurpbarros
Last active November 1, 2022 00:41
Show Gist options
  • Save arthurpbarros/bc35a644ed0238266f2cdca27f8d8143 to your computer and use it in GitHub Desktop.
Save arthurpbarros/bc35a644ed0238266f2cdca27f8d8143 to your computer and use it in GitHub Desktop.
Usa a biblioteca pandas para manipular, filtrar a coluna "DOI" de vários arquivos de bases de dados em CSV e gravá-la em um novo arquivo.
import pandas
doi_ids = []
for i in range(1,10):
nome_arquivo = f'PsycNET_Export({i}).csv'
print("File readed: %s" % nome_arquivo)
df = pandas.read_csv(nome_arquivo)
for index,row in df.iterrows():
doi_ids.append(row['DOI'])
output_file = open("outputDOIs.txt","w")
for doi in doi_ids:
new = doi.replace('https://doi.org/','')
output_file.write(new+"\n")
output_file.close()
print("File with all DOIs created!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment