Created
September 30, 2011 14:16
-
-
Save breuderink/1253855 to your computer and use it in GitHub Desktop.
Converter for SIKS dissertation list to LaTeX
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/env python | |
''' | |
Quick and dirty hack to get the SIKS dissertation list in LaTeX. | |
''' | |
import argparse, re, operator, itertools, sys | |
parser = argparse.ArgumentParser( | |
description='Convert SIKS dissertation list to LaTeX.') | |
parser.add_argument('txt') | |
parser.add_argument('tex') | |
parser.add_argument('-n', '--output-lines', type=int, default=100) | |
args = parser.parse_args() | |
dissertations = [] | |
with open(args.txt, 'r') as f: | |
for line in f: | |
match = re.search(r'\d{4}-\d+', line) | |
if match: | |
diss_id = match.group(0) | |
author = f.next().strip() | |
title = f.next().strip() | |
dissertations.append((diss_id, author, title)) | |
sorted_diss = sorted(dissertations, key=operator.itemgetter(0), reverse=True) | |
with open(args.tex, 'w') as f: | |
latex_cmd = r'\newcommand{\SIKSdiss}[3]{{\bf #1}\hspace*{1ex}#2, {\it #3.}\\}' | |
f.write('%s\n\n' % latex_cmd) | |
for diss in sorted_diss[:args.output_lines]: | |
f.write('\\SIKSdiss{%s}{%s}{%s}\n' % diss) |
Thanks for the work. I updated it to be a bit more flexible:
- specify a minimum year (currently SKIS does only require the list from 2011 on)
- added a SIKSyear command
If anyone is interested the updated version is here:
https://gist.github.com/fmannhardt/8fb552ea5a5b635d690960024b8aba07
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you for writing this! I used it to include the SIKS dissertation list in my thesis and it saved me a lot of work!
One tip: when you use Python 3, change "f.next()" to "f.readline()" on lines 21 and 22.