Last active
December 31, 2015 03:29
-
-
Save Nepomuk/7927919 to your computer and use it in GitHub Desktop.
Convert PANDAs collaboration member list to the DPG collaboration list LaTeX format. Joint effort with https://github.com/AndiH
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
\documentclass{scdpg} | |
\begin{document} | |
\scBookLanguage{de} | |
\begin{scCollaboration} | |
\scCollaborationName{PANDA} | |
#for $person in $persons | |
\scAuthor{}{$person.firstname}{$person.lastname}{$person.institute} | |
#end for | |
#for $key, $value in enumerate($institutes) | |
#set $id = $key + 1 | |
\scAffiliation{$id}{$value} | |
#end for | |
\scConference{Frankfurt 2014} | |
\scEmail{j.ritman@fz-juelich.de} | |
\end{scCollaboration} | |
\end{document} |
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
#!/usr/bin/python | |
# -*- coding: utf-8 | |
import argparse | |
import csv, xlrd | |
import latexcodec | |
from Cheetah.Template import Template | |
_skipFirstRow = True | |
def readCSV(inputFileName): | |
inputFile = open(inputFileName, 'rU') | |
return csv.reader(inputFile, delimiter=';', dialect=csv.excel_tab) | |
def importExcelFile(inputFileName, worksheetName='Tabelle1'): | |
excelfile = xlrd.open_workbook(inputFileName) | |
excelsheet = excelfile.sheet_by_name(worksheetName) | |
masterList = [] | |
for i in range(excelsheet.nrows): | |
masterList.append(excelsheet.row(i)) | |
return masterList | |
def boldenCityName(listOfInstitutes): | |
out = [] | |
for institute in listOfInstitutes: | |
splitInstitute = institute.split(", ") | |
print splitInstitute | |
city = splitInstitute[-2] | |
del splitInstitute[-2] | |
city = "{\\bf " + city + "}" | |
splitInstitute.insert(-1, city) | |
niceInstitute = ", ".join(splitInstitute) | |
out.append(niceInstitute) | |
return out | |
def writeOutputFile(listOfInstitutes, listOfPersons, outputFileName): | |
outFile = file(outputFileName, 'w') | |
t = Template(file="DPG_template.tex") | |
t.persons = listOfPersons | |
t.institutes = boldenCityName(listOfInstitutes) | |
outFile.write(str(t)) | |
outFile.close() | |
_namelookup = { | |
u"Czyżewski": u"Czyzewski", | |
u"Czyżycki": u"Czyzycki", | |
u"Gąciarz": u"Gaciarz", | |
u"Płażek": u"Płazek" | |
} | |
_instLookup = { | |
u"University of Glasgow, United Kingdom": u"University of Glasgow, Glasgow, United Kingdom", | |
u"University of Edinburgh United Kingdom": u"University of Edinburgh, Edinburgh, United Kingdom", | |
u"IRFU,SPHN, CEA Saclay, France": u"IRFU, SPHN, CEA Saclay, Saclay, France", | |
u"Università di Brescia, Italy": u"Università di Brescia, Brescia, Italy", | |
u"INFN Laboratori Nazionali di Frascati, Italy": u"INFN Laboratori Nazionali di Frascati, Frascati, Italy", | |
u"INFN Sezione di Genova, Italy": u"INFN Sezione di Genova, Genova, Italy", | |
u"KVI-Center for Advanced Radiation Technology (CART), University of Groningen, Netherlands": u"KVI-Center for Advanced Radiation Technology (CART), University of Groningen, Groningen, Netherlands", | |
u"Northwestern University, Evanston U.S.A.": "Northwestern University, Evanston, U.S.A.", | |
u"Universität Bochum, Institut für Experimentalphysik I, Germany": u'I. Institut für Experimentalphysik, Ruhr-Universität Bochum, Bochum, Germany', | |
u"Rheinische Friedrich-Wilhelms-Universität Bonn, Germany": u'Helmholtz-Institut fur Strahlen- und Kernphysik, Rheinische Friedrich Wilhelms-Universitat Bonn, Bonn, Germany', | |
u"Universität Basel, Switzerland": u"Universität Basel, Basel, Switzerland", | |
u"Friedrich Alexander Universität Erlangen-Nürnberg, Germany": u"Friedrich-Alexander-Universität Erlangen-Nürnberg, Erlangen, Germany", | |
u"Westfälische Wilhelms-Universität Münster, Germany": u"Westfälische Wilhelms-Universität Münster, Münster, Germany", | |
u"Sikaha-Bhavana, Visva-Bharati, Santiniketan, WB, India": u"Sikaha-Bhavana, Visva-Bharati University, Santiniketan, India", | |
u"Institut de Physique Nucléaire d’Orsay (UMR8608), CNRS/IN2P3 and Université Paris-sud, Orsay, France": u"Institut de Physique Nucléaire d'Orsay (UMR8608), CNRS/IN2P3 and Université Paris-sud, Orsay, France", | |
u"Institutul National de C&D pentru Fizica si Inginerie Nucleara “Horia Hulubei”, Bukarest-Magurele, Romania": u'Institutul National de C\&D pentru Fizica si Inginerie Nucleara ``Horia Hulubei", Bukarest-Magurele, Romania' # Because LaTeX | |
} | |
def cleanUpName(name, lookupTable): | |
if name in lookupTable: | |
correctname = lookupTable[name] | |
else: | |
correctname = name | |
return correctname | |
def main(): | |
parser = argparse.ArgumentParser(description='Convert PANDAs members.csv to the DPG-styled members.tex') | |
parser.add_argument('collabList', metavar='INPUTFILE', type=str, help='CSV list of PANDA') | |
args = parser.parse_args() | |
inputFileName = args.collabList | |
listOfInstitutes = [] | |
listOfPersons = [] | |
skippedFirstRow = False | |
for row in importExcelFile(inputFileName): | |
if _skipFirstRow and not skippedFirstRow: | |
skippedFirstRow = True | |
continue | |
lastname = row[1].value.strip()#.encode('latex') | |
firstname = row[2].value.strip()#.encode('latex') | |
institute = row[8].value.strip() | |
print firstname, lastname, institute | |
lastname = cleanUpName(lastname, _namelookup) | |
institute = cleanUpName(institute, _instLookup) | |
if institute not in listOfInstitutes: | |
listOfInstitutes.append(institute) | |
instituteID = listOfInstitutes.index(institute) | |
print listOfInstitutes | |
listOfPersons.append({'lastname': lastname, 'firstname': firstname, 'institute': instituteID+1}) | |
outputFileName = inputFileName[:-4] + '_dpg.tex' | |
writeOutputFile(listOfInstitutes, listOfPersons, outputFileName) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment