-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathophase-generate-beidseitig.py
110 lines (97 loc) · 2.75 KB
/
ophase-generate-beidseitig.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
## Wieviele Seiten sollen gedruckt werden (1 Seite = 10 Karten)
number_of_pages = 10
## Wo finden sich die Telefonnummern?
## CSV-Datei im Format Name,Telefonnummer
input_file = "nummern.csv"
## Wohin soll die LaTeX-Datei?
output_file = "ophase-karten.tex"
## Nummer der Kuh:
cownumber = "\\textbf{+49 163 2938224}"
## LaTeX-Formatierungsanweisungen
## Müssen u.U. je nach Drucker, Kuhgröße etc. angepasst werden
preamble = """\\documentclass[a4paper,tikz]{standalone}
\\begin{document}
"""
tablestart = "\\begin{tabular}{l r}\n"
tablecow = """\\textbf{Kuh} & """
tableend = """\\multicolumn{2}{p{45mm}}{\\centering\\textit{www.kuhlt.de}}
\\end{tabular}
"""
## 38.5 falls ohne Kuhnummer
intertable = """
\\vspace{33.5mm}
"""
intertable2 = """
\\vspace{30mm}
\\hspace{-200mm}
"""
pagetop = """
\\vspace*{22.5mm}
"""
pagetop2 = """
\\vspace*{5mm}
\\hspace{-10mm}
"""
newpage = """
\\newpage
"""
interentry1 = " & "
interentry2 = " & & "
entryend = " \\\\\n"
postscript = "\\end{document}"
bild = "\\includegraphics[scale=0.23, clip=true]{eintrittskarte.png}"
begintikz = "\\begin{tikzpicture}[xscale=10, yscale=6]"
endtikz = "\\end{tikzpicture}"
nodestart = "\\node at ("
comma = ","
nodebegincaption = ") {"
nodeend = "};\n"
## Das Programm selber
import csv
import random
reader = csv.reader(open(input_file, "r"), delimiter=',')
entries = []
for row in reader:
entries.append(row)
output = open(output_file, "w");
output.write(preamble);
for page in range(0, number_of_pages):
output.write(begintikz);
for i in range(0, 4):
for k in range(0, 2):
output.write(nodestart);
output.write(str(k));
output.write(comma);
output.write(str(i));
output.write(nodebegincaption);
er1 = random.sample(entries, 4)
output.write(tablestart)
for j in range(0, 4):
output.write(er1[j][0]);
output.write(interentry1);
output.write(er1[j][1]);
output.write(entryend);
## Kuhnummer drunter setzen
output.write(tablecow);
output.write(cownumber);
output.write(entryend);
## Kuhnummer ende
output.write(tableend);
output.write(nodeend);
output.write(endtikz);
# output.write(newpage);
output.write(begintikz);
for i in range(0, 4):
for k in range(0, 2):
output.write(nodestart);
output.write(str(-k));
output.write(comma);
output.write(str(i));
output.write(nodebegincaption)
output.write(bild);
output.write(nodeend);
output.write(endtikz);
# if page != number_of_pages-1:
# output.write(newpage)
output.write(postscript)
output.close()