In [49]:
import csv
import knmi
import numpy as np
# retrieve data from station 330 (Hoek van Holland)
df = knmi.get_day_data_dataframe([330], start='20170101', end='20171231',
variables=['TG','RH','UG','Q','PG'])
# drop station column
df = df.drop('STN', axis=1)
# convert units from KNMI to SI
df = df.apply(lambda x: x * np.asarray([1e-1, 1e-1/24, 1e4, 1, 1e-2]), axis=1)
# convert index from datatime to seconds
df.index = (df.index - df.index[0]).total_seconds()
# save file
df.to_csv('meteo.txt', sep=' ', header=False, float_format='%0.4f', quoting=csv.QUOTE_NONE)