-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.py
33 lines (24 loc) · 920 Bytes
/
run.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
# encoding: utf-8
"""Tests for browsing the api."""
from siris.scraper import SirisScraper
# Init scraper
scraper = SirisScraper()
# List all schooltypes
verksamhetsformer = scraper.items
# [<Verksamhetsform: 15 (Fritidshem)>, <Verksamhetsform: 10 (Förskola)>, <Verksamhetsform: 14 (Förskoleklass)>,... ]
# Select a schooltype
verksamhetsform = verksamhetsformer.get_by_label(u"Öppen förskola")
# List all available datasets
datasets = verksamhetsform.items
# [<SirisDataset: 40 (Kostnader per kommun)>...]
# Select a dataset
dataset = datasets.get_by_label("Kostnader per kommun")
# Make a query
res = dataset.fetch() # Get latest available data
#res = dataset.fetch({"period": "2015"}) # Get data for a given period
#res = dataset.fetch({"period": "*"}) # Get data all periods
# List all avilable periods
print(dataset.periods)
# Use the result
# ...in Python Pandas for example
dataframe = res.pandas