提供苏黎世水保警察现场和历史天气数据。
fhnw-ds-hs2019-weatherstation-api的Python项目详细描述
此库提供对Wasserschutzpolizei Zurich实时(使用此REST API)和历史(使用这些CSV files)天气数据的访问。
安装
sudo pip3 install fhnw_ds_hs2019_weatherstation_api
下载历史数据
mkdir data &&cd data wget https://raw.githubusercontent.com/markif/WeatherStation_HS2019/master/data/messwerte_mythenquai_2007-2018.csv wget https://raw.githubusercontent.com/markif/WeatherStation_HS2019/master/data/messwerte_tiefenbrunnen_2007-2018.csv wget https://raw.githubusercontent.com/markif/WeatherStation_HS2019/master/data/messwerte_mythenquai_2019.csv wget https://raw.githubusercontent.com/markif/WeatherStation_HS2019/master/data/messwerte_tiefenbrunnen_2019.csv cd ..
用法
#!/usr/bin/env python3# import the libraryfromfhnw_ds_hs2019_weatherstation_apiimportdata_importasweatherimportos# DB and CSV configconfig=weather.Config()# define CSV pathconfig.historic_data_folder='.'+os.sep+'data'# set batch size for DB inserts (decrease for raspberry pi)config.historic_data_chunksize=10000# define DB hostconfig.db_host='localhost'# connect to DBweather.connect_db(config)# clean DBweather.clean_db(config)# import historic dataweather.import_historic_data(config)# import latest data (delta between last data point in DB and current time)weather.import_latest_data(config)