mel mel - 7 months ago 79
JSON Question

Loading a json file in python

I've got multiple file to load as JSON, they are all formatted the same way but for one of them I can't load it without raising an exception. This is where you can find the file:


I did the following code:

def from_seed_data_extract_summoners():
summonerIds = set()
for i in range(1,11):
file_name = 'data/matches%s.json' % i
print file_name
with open(file_name) as data_file:
data = json.load(data_file)
for match in data['matches']:
for summoner in match['participantIdentities']:
return summonerIds

The error occurs when I do the following:
. I suppose there is a special character but I can't find it and don't know how to replace it. The error generated is:

UnicodeDecodeError: 'utf8' codec can't decode byte 0xeb in position 6: invalid continuation byte

Do you know how I can get ride of it?

ntg ntg


json.loads(unicode(, errors='ignore'))

or :

json.loads(unidecode.unidecode(unicode(, errors='ignore')))

(for the second, you would need to install unidecode)