Created
October 15, 2018 18:02
-
-
Save christopherkullenberg/6b104dd0bdaea4ce58960deb558fce44 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
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 49, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"import pandas as pd\n", | |
"import subprocess" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 50, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"df = pd.read_csv(\"nameandemail.csv\")" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 51, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"#df.head()" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 52, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"header = '''\n", | |
"<!--\n", | |
"pandoc -V fontsize=12pt -V papersize:\"a4paper\" -V geometry:\"top=2cm, bottom=3cm, left=3cm, right=3cm\"\n", | |
"-->\n", | |
"\n", | |
"![logga GU](https://www.gu.se/digitalAssets/702/702071_logtotyp_1.gif){ width=25% }\\ Göteborg den 7 november 2018.\n", | |
"\n", | |
"Institutionen för Filosofi, Lingvistik och Vetenskapsteori\n", | |
"\n", | |
"<!-- Dessa gör blanksteg -->\n", | |
"\n", | |
" \n", | |
"\n", | |
" \n", | |
"\n", | |
" \n", | |
"\n", | |
"**INTYG**\n", | |
"\n", | |
"**Introduktionskurs i webbpublicering**\n", | |
"\n", | |
"Härmed intygas att **'''\n", | |
"\n", | |
"footer = '''** har genomgått\n", | |
"introduktionskurs i webbpublicering (WordPress) inom ramen för\n", | |
"Kommunikatörsprogrammet med inriktning mot myndigheter och offentlig\n", | |
"förvaltning vid Institutionen för filosofi, lingvistik och\n", | |
"vetenskapsteori, Göteborgs universitet. Ansvarig lärare för kursen var\n", | |
"Erik Eliasson, universitetsadjunkt vid Institutionen för journalistik,\n", | |
"medier och kommunikation.\n", | |
"\n", | |
" \n", | |
"\n", | |
" \n", | |
"\n", | |
" \n", | |
"\n", | |
" \n", | |
"\n", | |
" \n", | |
"\n", | |
" \n", | |
"\n", | |
"Fil. dr Christopher Kullenberg, Docent i Vetenskapsteori.\n", | |
"\n", | |
"Koordinator för Kommunikatörsprogrammet med inriktning mot myndigheter och offentlig förvaltning\n", | |
"\n", | |
"E-post: christopher.kullenberg@gu.se'''" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 54, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"with open(\"intyghelaklassen.md\", \"w\") as file:\n", | |
" file.write(r'''\\pagenumbering{gobble}''')\n", | |
" for names in df.iterrows():\n", | |
" content = header + names[1][0] + \" \" + names[1][1] + footer\n", | |
" file.write(content)\n", | |
" file.write(r'''\\newpage''')\n", | |
" # print(header + names[1][0], names[1][1] + footer)\n", | |
" # print(r'''\\newpage''')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 55, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"CompletedProcess(args=['pandoc', '-V', 'fontsize=12pt', '-V', 'papersize:\"a4paper\"', '-V', 'geometry:margin=1in', 'intyghelaklassen.md', '-o', 'intyghelaklasen.pdf'], returncode=0, stdout=b'')" | |
] | |
}, | |
"execution_count": 55, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"subprocess.run(['pandoc', \n", | |
" '-V', 'fontsize=12pt', '-V',\n", | |
" 'papersize:\"a4paper\"', '-V', 'geometry:margin=1in',\n", | |
" 'intyghelaklassen.md', '-o', 'intyghelaklasen.pdf'], stdout=subprocess.PIPE)" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.5.5" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment