Skip to content

Instantly share code, notes, and snippets.

@lhoupert
Created July 13, 2020 18:00
Show Gist options
  • Save lhoupert/03a0709980d4cf9a8ab88de58e447bcf to your computer and use it in GitHub Desktop.
Save lhoupert/03a0709980d4cf9a8ab88de58e447bcf to your computer and use it in GitHub Desktop.
Convert xls spreadsheet to yaml file
from pathlib import Path
import ruamel.yaml
import pandas as pd
yaml = ruamel.yaml.YAML()
df = pd.read_excel('../scopus_vexport_with_manualedit_202008.xlsx')
print (df)
# df.columns returns:
# Index(['Authors', 'Authorsv2', 'Authors (short)', 'Author position', 'Title', 'Journal Info',
# 'Year', 'Article Code', 'IF', 'Cited by',
# 'Quartile and Area', 'ISSN', 'H Index', 'Hyperlink', 'DOI', 'DOI link',
# 'Publisher', 'ISBN', 'CODEN', 'Document Type', 'Publication Stage',
# 'Access Type', 'Source', 'EID', 'Unnamed: 24', 'Journal', 'JournalAbr',
# 'Volume', 'Page start', 'Page end'],
# dtype='object')
il = 0;
publis = []
for il in range(len(df)):
aa = dict(num='('+str(len(df)-il)+')',
title=df.loc[il,'Title'] ,
authors=df.loc[il,'Authorsv2'],
journal='*'+df.loc[il,'Journal']+'*',
year= str(df.loc[il,'Year']),
doi=df.loc[il,'DOI'],
doilink=df.loc[il,'DOI link'],
)
publis.append(aa)
with open('publis.yml', 'w') as f:
data = yaml.dump(publis, f)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment