kipe / nordpool

Python library for fetching Nord Pool spot prices.
MIT License
105 stars 39 forks source link

KeyError: 'currency' #31

Closed flopp999 closed 1 month ago

flopp999 commented 2 years ago

Debian 11.5 Nordpool 0.3.3

Sometimes I get an error like below. Any ideas what it can be?

Traceback (most recent call last):
File "/home/debian/Nordpool_Influx.py", line 20, in <module>
price=prices_spot.hourly(end_date=datetime.now().date(),areas=["SE4"])
File "/usr/local/lib/python3.9/dist-packages/nordpool/elspot.py", line 132, in hourly
return self.fetch(self.HOURLY, end_date, areas)
File "/usr/local/lib/python3.9/dist-packages/nordpool/elspot.py", line 128, in fetch
return self._parse_json(self._fetch_json(data_type, end_date), areas)
File "/usr/local/lib/python3.9/dist-packages/nordpool/elspot.py", line 37, in _parse_json
currency = data['currency']
KeyError: 'currency'

this is my python3.9 code

field = "SE4" prices_spot = elspot.Prices("SEK") price=prices_spot.hourly(end_date=datetime.now().date(),areas=["SE4"])

vhartikainen commented 1 year ago

I started getting this too after the nordpoolgroup API started responding HTTP 500. Seems like these errors are not handled gracefully in the code. I'll try pushing a PR later.

kipe commented 1 month ago

Closing, as not most likely present on 0.4.0 anymore.