Esempio n. 1
0
def main(key):
    configs.configure_logging()

    download_cycle_data(configs.cycling_data_index,
                        configs.cycling_data_dl_dir)
    unzip_2012_2024_cycling_data(configs.usage_stats, configs.usage_stats)
    clean_data(configs.usage_stats, configs.restructured_data_dir)
    merge_files(configs.restructured_data_dir, configs.merged_cycle_data_file)

    init_weather_download(key, configs.weather_data_dl_dir,
                          configs.weather_data_city)
    save_weather_codes(configs.weather_data_dl_dir, configs.weather_data_codes)
    write_weather_data(configs.weather_data_dl_dir, configs.weather_data_csv,
                       configs.EOL)
Esempio n. 2
0
    for file in files:
        path = os.path.join(folder, file)
        with open(path) as f:
            data = json.load(f)['data']

            if 'error' in data: continue
            for weather in data['weather']:
                date = weather['date']
                for hour in weather['hourly']:
                    time = hour['time']
                    temperature = hour['tempC']
                    feels = hour['FeelsLikeC']
                    wind = hour['windspeedKmph']
                    weather_code = hour['weatherCode']
                    hour = int(time) / 100
                    d = datetime.time(hour=int(hour), minute=0, second=0)
                    final_date = f'{date} {d.isoformat()}'

                    with open(output_file, 'a') as dataset:
                        dataset.write(','.join([
                            final_date, temperature, feels, wind, weather_code
                        ]))
                        dataset.write(eol)


if __name__ == '__main__':
    import configs
    configs.configure_logging()
    write_weather_data(configs.weather_data_dl_dir, configs.weather_data_csv,
                       configs.EOL)