config.read(configfile)
apikey = config.get('openweathermap', 'apikey')
cityid = config.get('openweathermap', 'cityid')
+ csvfile = config.get("openweathermap", 'csvfilename')
weather_raw = getweather(apikey, cityid)
if debug:
# write to db
# write to csv
- write_csv(config.get("openweathermap", 'csvfilename'), weather)
+ write_csv(os.path.expanduser(csvfile), weather)
if __name__ == '__main__':
def writesensordatacsv(config, sensor_id, sensor_name, timestamp, value_type, value_raw, value):
# Schreiben des csv-files
- file = open(config.get("csv", "filename"), "a", newline = "")
+ file = open(os.path.expanduser(config.get("csv", "filename")), "a", newline = "")
writer = csv.writer(file, dialect = "excel")
writer.writerow([timestamp.strftime("%Y-%m-%d %H:%M"), sensor_id, sensor_name, "{:.1f}".format(value)])