23 lines
686 B
Python
23 lines
686 B
Python
import pandas as pd
|
|
import urllib.request
|
|
import json
|
|
import requests
|
|
|
|
def determine_month():
|
|
ds = pd.read_excel(urllib.request.urlopen('https://sundogbaelt.dk/wp-content/uploads/2019/04/trafiktal-maaned.xls'))
|
|
|
|
cur_year = 2019
|
|
amount_of_cur_year = sum([x == cur_year for x in ds['År']])
|
|
|
|
cur_year_total = sum(ds['Total'][1:amount_of_cur_year+1])
|
|
last_year_total = sum(ds['Total'][amount_of_cur_year+1:amount_of_cur_year+13])
|
|
|
|
return ((12/(last_year_total//cur_year_total))+1), cur_year_total, last_year_total
|
|
|
|
|
|
|
|
def write_json(url, data_name, time):
|
|
r = requests.get(url)
|
|
with open(f"{data_name}_{time}.json", 'w') as f:
|
|
json.dump(r.json(), f)
|