Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Google Translate API error

I am very to new to python and trying to translate a bunch of keywords using google API. I have an excel file with 3000 keywords which are mix of english, spanish, german etc. Trying to translate everything to English.

However, every time I run my code, I get error at different values. Sometimes, my code give error at 810th keyword while sometime it gives error at 1038 keyword. And I am not even editing the layout of the file.

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Below is my code:

from googletrans import Translator
import pandas
import math
import time
df = pandas.read_excel(r'Desktop/python_keywords.xlsx')
keywords = df['Keywords']
Translate = []
translator = Translator()

for i in range(0,len(keywords)):
    word = translator.translate(str(keywords[j])).text
    Translate.append(word)
like image 555
prasadav Avatar asked Jun 07 '26 08:06

prasadav


1 Answers

Normally this error is due to the character limit of 15K in Googletrans API.

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Consider reducing the number of characters.

like image 188
Ravi Avatar answered Jun 10 '26 06:06

Ravi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!