Commit 11e9e4ae authored by Loic Huder's avatar Loic Huder
Browse files

Added correction for meteo 1.2

parent 2e306d2a
#!/usr/bin/env python3
#-*- coding: utf-8 -*-
def load_data(file_path):
""" Loading the data in multiple dictionaries """
station = ""
wind = {}
temperature = {}
humidity = {}
rainfall = {}
with open(file_path) as f:
f.readline()
for line in f:
value_fields = line.split(",")
date = value_fields[1]
# Format date to remove minutes and seconds
formatted_date = date.split(":")[0]
# Add to dicts
wind[formatted_date] = float(value_fields[2])
temperature[formatted_date] = float(value_fields[3]) - 273.15
humidity[formatted_date] = float(value_fields[4])
raw_rainfall = value_fields[5]
if raw_rainfall.strip() == "":
rainfall[formatted_date] = 0.
else:
rainfall[formatted_date] = float(raw_rainfall)
station = value_fields[6].strip()
return station, wind, temperature, humidity, rainfall
station_name, station_wind, station_temp, station_humidity, station_rainfall = load_data('../data/synop-2016.csv')
print(station_name, station_temp)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment