@SIA wrote:
Hi - I’ve been trying to do the dress for the weather project. https://projects.raspberrypi.org/en/projects/dress-for-the-weather/ I ran into an issue early on - the JSON list downloaded from the API was different - there is a new line after each value, while in the JSON list on github the values are all in the same line. (So when I’d do cities[0] it would return /n…) I replaced the JSON list I’d downloaded with the one on Github, which worked, and was able to convert the list to a dictionary. But I haven’t been able to go further: when I tried to test it in the shell (https://projects.raspberrypi.org/en/projects/dress-for-the-weather/7) it returned this error. Can anyone help me figure out what’s going on? Thank you!
>>> get_city_id() Traceback (most recent call last): File "<pyshell#7>", line 1, in <module> get_city_id() File "/home/dress-for-the-weather/weather.py", line 8, in get_city_id data = [loads(line) for line in f] File "/home/dress-for-the-weather/weather.py", line 8, in <listcomp> data = [loads(line) for line in f] File "/home/anaconda3/lib/python3.6/json/__init__.py", line 354, in loads return _default_decoder.decode(s) File "/home/anaconda3/lib/python3.6/json/decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "/home/anaconda3/lib/python3.6/json/decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 2 column 1 (char 1)
Posts: 3
Participants: 2