Skip to content
Snippets Groups Projects
Commit e97f42fc authored by root's avatar root
Browse files

Added input and outputs for example 01, 02 and 03. Also some code...

Added input and outputs for example 01, 02 and 03. Also some code improvements, eg. removal of complicated proxy code
parent de7f5637
No related branches found
No related tags found
No related merge requests found
...@@ -4,20 +4,12 @@ import json ...@@ -4,20 +4,12 @@ import json
# This is an example to extract 10 persons with the highest income of each year from a rather difficult designed json # This is an example to extract 10 persons with the highest income of each year from a rather difficult designed json
# These are proxy settings. If you are behind a proxy just comment them in and swap the ip and port with your proxy
proxy_support = ProxyHandler({"http": "http://10.65.117.35:3128", #<proxy-ip>:<proxy-port>",
"https": "http://10.65.117.35:3128"}) #<proxy-ip>:<proxy-port>"}) # maybe you need to use https instead of http in the address depending on your proxy settings
opener = build_opener(proxy_support)
install_opener(opener)
# The url to download the json # The url to download the json
url = "https://phpefi.schleswig-holstein.de/vo/vo_opendata/export.json" url = "https://phpefi.schleswig-holstein.de/vo/vo_opendata/export.json"
# store the response of the request # Read json file
response = urlopen(url) with open("export.json") as f:
data_json = json.load(f)
# converting the response into a json
data_json = json.loads(response.read())
# Now due to bad data quality and not ideal data format we adjust the json to be better convertable to a table # Now due to bad data quality and not ideal data format we adjust the json to be better convertable to a table
data_json = data_json["Unternehmen"] data_json = data_json["Unternehmen"]
......
This diff is collapsed.
01_HighestSalaries/output.png

124 KiB

This diff is collapsed.
...@@ -3,32 +3,8 @@ import matplotlib.pyplot as plt ...@@ -3,32 +3,8 @@ import matplotlib.pyplot as plt
# Dieses Beispiel erstellt ein Histogram der Nabenhoehe von Windkraftanlagen aus einer csv Datei # Dieses Beispiel erstellt ein Histogram der Nabenhoehe von Windkraftanlagen aus einer csv Datei
###################################################################################################
# WITH PROXY
#from urllib.request import urlopen, ProxyHandler, build_opener, install_opener
#import io
# These are proxy settings. If you are behind a proxy just comment them in and swap the ip and port with your proxy
#proxy_support = ProxyHandler({"http": "http://<proxy-ip>:<proxy-port>",
# "https": "http://<proxy-ip>:<proxy-port>"}) # maybe you need to use https instead of http in the address depending on your proxy settings
#opener = build_opener(proxy_support)
#install_opener(opener)
# The url to download the json
#url = "https://opendata.schleswig-holstein.de/collection/windkraftanlagen/aktuell.csv"
# store the response of the request and unpack it
#response = urlopen(url)
#csv_byte = response.read()
# read the csv file, interpret ';' as the seperator of columns and ',' as a decimal indicator and convert it to '.' as decimal indicator
#df = pd.read_csv(io.StringIO(csv_byte.decode("utf-8")), sep=';', decimal=',')
###################################################################################################
# WITHOUT PROXY:
# read the csv file, interpret ';' as the seperator of columns and ',' as a decimal indicator and convert it to '.' as decimal indicator in the table # read the csv file, interpret ';' as the seperator of columns and ',' as a decimal indicator and convert it to '.' as decimal indicator in the table
df = pd.read_csv("https://opendata.schleswig-holstein.de/collection/windkraftanlagen/aktuell.csv", sep=';', decimal=',') df = pd.read_csv("aktuell.csv", sep=';', decimal=',')
###################################################################################################
# Drop unwanted columns. Comment out the columns to keep. # Drop unwanted columns. Comment out the columns to keep.
# You can use print(df.columns) to see all available columns # You can use print(df.columns) to see all available columns
...@@ -58,6 +34,7 @@ df_clean = df.dropna(subset=[column_of_interest]) ...@@ -58,6 +34,7 @@ df_clean = df.dropna(subset=[column_of_interest])
df_clean[column_of_interest].hist(bins=25, rwidth=.9) df_clean[column_of_interest].hist(bins=25, rwidth=.9)
# Put labels on the x and y axis # Put labels on the x and y axis
plt.title("Wind Turbines")
plt.xlabel(column_of_interest.title()) plt.xlabel(column_of_interest.title())
plt.ylabel("Anzahl") plt.ylabel("Anzahl")
plt.savefig("histogram.png") plt.savefig("histogram.png")
......
02_WindTurbines/histogram.png

16.2 KiB | W: | H:

02_WindTurbines/histogram.png

18.2 KiB | W: | H:

02_WindTurbines/histogram.png
02_WindTurbines/histogram.png
02_WindTurbines/histogram.png
02_WindTurbines/histogram.png
  • 2-up
  • Swipe
  • Onion skin
03_MonumentsSlideshow/denkmal_imgs/img_000.jpg

140 KiB

This diff is collapsed.
import pandas as pd
from urllib.request import urlopen, ProxyHandler, build_opener, install_opener
import json import json
import os import os
import wget import wget
# Dieses Beispiel erstellt eine Slideshow aus Bildern von Denkmälern in Neumünster, die URLs zu den Bildern sind in einer JSON Datei # Dieses Beispiel erstellt eine Slideshow aus Bildern von Denkmälern in Neumünster, die URLs zu den Bildern sind in einer JSON Datei
# These are proxy settings. If you are behind a proxy just comment them in and swap the ip and port with your proxy # Add proxy settings if needed
#proxy_support = ProxyHandler({"http": "http://<proxy-ip>:<proxy-port>", # proxy = 'http://10.65.117.35:3128'
# "https": "http://<proxy-ip>:<proxy-port>"}) # maybe you need to use https instead of http in the address depending on your proxy settings # os.environ['http_proxy'] = proxy
#opener = build_opener(proxy_support) # os.environ['HTTP_PROXY'] = proxy
#install_opener(opener) # os.environ['https_proxy'] = proxy
# os.environ['HTTPS_PROXY'] = proxy
# Die url zu der json datei # Die url zu der json datei
url = "https://opendata.schleswig-holstein.de/dataset/eddb1d7e-7df3-421a-97c7-447e1b78c94c/resource/d413e41c-b13e-4984-8dbe-4725a9a188ec/download/denkmalliste.json" url = "https://opendata.schleswig-holstein.de/dataset/eddb1d7e-7df3-421a-97c7-447e1b78c94c/resource/d413e41c-b13e-4984-8dbe-4725a9a188ec/download/denkmalliste.json"
# download der json # Read json file
response = urlopen(url) with open("denkmalliste.json") as f:
data_json = json.load(f)
# Lies die Json aus der Response aus
data_json = json.loads(response.read())
# Sammle die Fotos und die dazugehörigen Bezeichnungen aller Denkmäler in einer Liste # Sammle die Fotos und die dazugehörigen Bezeichnungen aller Denkmäler in einer Liste
FotoURL_list = [] FotoURL_list = []
...@@ -29,8 +26,8 @@ for denkmal in data_json: ...@@ -29,8 +26,8 @@ for denkmal in data_json:
# Speichere "max" Anzahl an images in dem Ordner denkmal_imgs # Speichere "max" Anzahl an images in dem Ordner denkmal_imgs
max = 10 max = 10
os.makedirs("denkmal_imgs", exist_ok=True)
output_dir = "./denkmal_imgs/" output_dir = "./denkmal_imgs/"
os.makedirs(output_dir, exist_ok=True)
file_list = [] file_list = []
i = 0 i = 0
for img, bezeichnung in FotoURL_list[:max]: for img, bezeichnung in FotoURL_list[:max]:
...@@ -71,6 +68,6 @@ for i in range(len(file_list[:max])-1): ...@@ -71,6 +68,6 @@ for i in range(len(file_list[:max])-1):
else: else:
create_slideshow_command += f" [fa{i-1}][a{i+1}]xfade=transition={transition}:duration={duration_transition}:offset={(i+1) * (duration_image - duration_transition)}[fa{i}];" create_slideshow_command += f" [fa{i-1}][a{i+1}]xfade=transition={transition}:duration={duration_transition}:offset={(i+1) * (duration_image - duration_transition)}[fa{i}];"
create_slideshow_command += " -map \"[fa{}]\" -r 25 -vcodec libx264 slideshow.mp4".format(len(file_list[:max])-2) create_slideshow_command += " -map \"[fa{}]\" -r 25 -vcodec libx264 slideshow2.mp4".format(len(file_list[:max])-2)
# Der Befehl wird an das System übergeben # Der Befehl wird an das System übergeben
os.system(create_slideshow_command) os.system(create_slideshow_command)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment