Downloading and extracting a zip file
The snippet can be accessed without any authentication.
Authored by
David Huckebrink
This snippet downloads and extracts a zip file from the german weather service.
responses_zip.py 525 B
import zipfile
from io import BytesIO
import pandas as pd
dwd_temp_zip = requests.get("https://opendata.dwd.de/climate_environment/CDC/observations_germany/climate/hourly/air_temperature/historical/stundenwerte_TU_00555_20080101_20181101_hist.zip")
buffer = BytesIO(dwd_temp_zip.content)
with zipfile.ZipFile(buffer) as zf:
# lists contents of zip archive
# zf.infolist()
with zf.open("produkt_tu_stunde_20080101_20181101_00555.txt") as le_file:
df = pd.read_csv(le_file,sep=";")
df.to_csv("test.csv")
Please register or sign in to comment