-
Notifications
You must be signed in to change notification settings - Fork 0
/
datawrapper.py
42 lines (29 loc) · 1.14 KB
/
datawrapper.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
import requests
def publish(id):
url = "https://api.datawrapper.de/v3/charts/" + id + "/publish"
headers = {
"Authorization": "Bearer aelzLABx3KGEcdGdhk1hBTrypJYTMAkje2xmexNLQm8e5GHAQsVQqneivIFURORK"
}
response = requests.request("POST", url, headers=headers)
def update_sat():
f = open("AppData/saturations.txt", "rt")
url = "https://api.datawrapper.de/v3/charts/n02gP/data"
headers = {
"Authorization": "Bearer aelzLABx3KGEcdGdhk1hBTrypJYTMAkje2xmexNLQm8e5GHAQsVQqneivIFURORK",
'content-type': "text/csv"
}
plaintext = f.read()
plaintext.encode('utf-8')
response = requests.request("PUT", url, headers=headers, data=plaintext)
publish("n02gP")
def update_cap():
f = open("AppData/capacities.txt", "rt")
url = "https://api.datawrapper.de/v3/charts/2lDyq/data"
headers = {
"Authorization": "Bearer aelzLABx3KGEcdGdhk1hBTrypJYTMAkje2xmexNLQm8e5GHAQsVQqneivIFURORK",
'content-type': "text/csv"
}
plaintext = f.read()
plaintext.encode('utf-8')
response = requests.request("PUT", url, headers=headers, data=plaintext)
publish("2lDyq")