-
Notifications
You must be signed in to change notification settings - Fork 10
/
boards2tsv.py
executable file
·33 lines (31 loc) · 1.04 KB
/
boards2tsv.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
#!/usr/bin/env python3
from urllib.request import Request, urlopen
from urllib.parse import urlparse
import csv
import json
import io
# Crowdsourced information about Dataverse installations
crowd_url = 'https://docs.google.com/spreadsheets/d/1bfsw7gnHlHerLXuk7YprUT68liHfcaMxs1rFciA-mEo/export?gid=0&format=tsv'
response = urlopen(crowd_url)
crowd_string = response.read().decode(response.info().get_param('charset') or 'utf-8')
reader = csv.DictReader(io.StringIO(crowd_string), delimiter="\t")
rows = [row for row in reader]
with open('boards.tsv', 'w', newline='') as tsvfile:
output = csv.writer(tsvfile, delimiter='\t')
header = [
'Board URL HTML',
'Board URL JSON',
'Installation hostname',
]
output.writerow(header)
for row in rows:
board_html_url = row['board']
if not board_html_url:
continue
board_api_url = row['board_api']
hostname = row['hostname']
output.writerow([
board_html_url,
board_api_url,
hostname,
])