Skip to content

Commit

Permalink
ready
Browse files Browse the repository at this point in the history
  • Loading branch information
jamct committed Jul 8, 2022
1 parent f6f08c1 commit e153f3c
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 41 deletions.
1 change: 1 addition & 0 deletions .env-example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
API_KEY=IHR-KEY
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Getting started

* Copy .env-example to .env and add your API key for AGSI+
* Install dependencies with `pip install altair pandas python-dotenv`
* Run script with `python create.py`
* Enjoy your diagram (data.html)
22 changes: 16 additions & 6 deletions create.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
import requests
import altair as alt
import pandas as pd
import pandas as pd
import os
from dotenv import load_dotenv

load_dotenv()

url = 'https://agsi.gie.eu/api'

params = {
"country": "de",
"from": "2022-01-31",
"from": "2022-01-02",
"size": 300
}

headers = {
"x-key" : "<KEY>"
head = {
"x-key" : os.environ.get("API_KEY")
}

resp = requests.get(url=url, params=params, headers=headers)
resp = requests.get(url=url, params=params, headers=head)
data = resp.json()

if not data['data']:
exit("Error reading data from api. Check API key")

df = pd.json_normalize(data['data'])
df['full'] = df['full'].astype(float)
df['injection'] = df['injection'].astype(float)
Expand All @@ -31,6 +39,8 @@
bar = base.mark_bar(color='green').encode(y = alt.Y('injection',
axis=alt.Axis(title ="Einspeisung [GWh/d]") ))

(line+bar).properties(height=600, width=1200, title='Gasspeicher in Deutschland' ).resolve_scale(
diagram = line+bar

diagram.properties(height=600, width=1200, title='Gasspeicher in Deutschland' ).resolve_scale(
y = 'independent'
).save('data.html')
35 changes: 0 additions & 35 deletions data.html

This file was deleted.

0 comments on commit e153f3c

Please sign in to comment.