-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate-table.py
executable file
·37 lines (26 loc) · 1.15 KB
/
generate-table.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
#
# Prints out a table to display all relations from newspapers to nuts areas
#
import pandas as pd
df = pd.read_csv('zeitungen-mit-nuts.csv')
def header(cols):
print("<thead>")
print("<tr>")
for c in cols:
print(" <th>{}</th>".format(c))
print("</tr>")
print("</thead>")
def row(cols):
print("<tr>")
for c in cols:
print(" <td>{}</td>".format(c))
print("</tr>")
def link(name, href):
return '{} <a href="{}"><img alt="Wikidata-logo.svg" src="https://upload.wikimedia.org/wikipedia/commons/thumb/f/ff/Wikidata-logo.svg/20px-Wikidata-logo.svg.png" decoding="async" srcset="//upload.wikimedia.org/wikipedia/commons/thumb/f/ff/Wikidata-logo.svg/30px-Wikidata-logo.svg.png 1.5x, //upload.wikimedia.org/wikipedia/commons/thumb/f/ff/Wikidata-logo.svg/40px-Wikidata-logo.svg.png 2x" data-file-width="1050" data-file-height="590" width="20" height="11"></a>'.format(name, href)
print('<table id="example" class="table table-striped" style="width:100%">')
header(['zeitung', 'nuts3', 'nuts3-name'])
print("<tbody>")
for e in df.values:
row([link(e[2], e[1]), e[3], link(e[4], e[5])])
print("</tbody>")
print("</table>")