When I try to load data from excel using
models = json.loads(my_column_with_JSon_data)["template"]["module"]
I get errors as:
- Expecting ',' delimiter: line 1 column 458 (char 457)
- json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 1 column 319 (char 318)
- json.decoder.JSONDecodeError: Expecting ':' delimiter: line 1 column 268 (char 267)
I understand there's a problem with my data, some delimiter missing, double quotes, etc and I saw there are different answers on stackoverflow according to each error on a specific set of data. That doesn't help me though - I can't manually modify my dataset since it is changing being scraped every time before using (different data).
My question is: is there a way/formula/logic to use in order to solve this errors without manual modification of data?
One mention here: JSon data is scraped from web and comes in a correct format but after using Amazon Translation model, it gets modified.
This code is used for translating the text:
for index, row in df3.iterrows():
el1= row['col_1']
tg = row['target']
srs = row['source']
text = row['to_be_translated']
result = translate.translate_text(Text=text, SourceLanguageCode=sc,
TargetLanguageCode=tg)
tg_text = res.get('TranslatedText')
tg_text = tg_text.replace('#- ', '#')
content.append(
{'col_1': el1,'source': srs, 'translated': text, 'target': tg,
'translated_output': tg_text})
output = dfFinalData.append(content)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…