fluves / pywaterinfo

Python package to download time series data from waterinfo.be
https://fluves.github.io/pywaterinfo/
MIT License
17 stars 9 forks source link

HIC get_timeseries_list request not working #56

Closed JoniDH closed 1 year ago

JoniDH commented 1 year ago

Description

I tried to get an overview of the locations with daily HIC depth measurements.

What I Did

H_stations_hic = hic.get_timeseries_list(parametertype_name='H', ts_name = 'DagGem')
Traceback (most recent call last):

  File "<ipython-input-17-e7a6f63b481b>", line 1, in <module>
    H_stations_hic = hic.get_timeseries_list(parametertype_name='H', ts_name = 'DagGem')

  File "~\Anaconda3\lib\site-packages\pywaterinfo\waterinfo.py", line 825, in get_timeseries_list
    data, response = self.request_kiwis(query_param)

  File "~\Anaconda3\lib\site-packages\pywaterinfo\waterinfo.py", line 221, in request_kiwis
    parsed = res.json()

  File "~\Anaconda3\lib\site-packages\requests\models.py", line 900, in json
    return complexjson.loads(self.text, **kwargs)

  File "~\Anaconda3\lib\json\__init__.py", line 357, in loads
    return _default_decoder.decode(s)

  File "~\Anaconda3\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())

  File "~\Anaconda3\lib\json\decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)

JSONDecodeError: Invalid control character at
johanvdw commented 1 year ago

It looks like the server is improperly escaping special characters. This is most likely not a bug in pywaterinfo but in the Kisters software.

As these special characters appear in comments, you can still fetch the list of timeseries by specifying which variables you are interested in, eg:

H_stations_hic = hic.get_timeseries_list(parametertype_name='H', ts_name = 'DagGem', returnfields="ts_id,station_name,stationparameter_longname,station_local_x,station_local_y")

see https://hicws.vlaanderen.be/KiWIS/KiWIS?service=kisters&type=queryServices&request=getRequestInfo for an overview of possible variables.

stijnvanhoey commented 1 year ago

@JoniDH does this work and were you able to extract the data?

JoniDH commented 1 year ago

@JoniDH does this work and were you able to extract the data?

Yes! Thanks a lot for your quick response