I’m getting this error “Time out” with this code, using Google trans Api in python , I need to translate 1500 rows from dutch to french in python, in an Excel file :

import pandas as pd
from googletrans import Translator
import time
from requests.exceptions import ReadTimeout

# Read the Excel file
df = pd.read_excel('2VeganPrixAug.xlsx')
print("Excel file loaded successfully.")
# //imprime le type de la colonne de la colonne "h"
print(df['description'].dtype)
# transforme la colonne en string
df['description'] = df['description'].astype(str)
print(df['description'].dtype)
#print the first 5 rows of the column "description"
print(df['description'].head())

# Ou bien, si vous souhaitez traiter chaque élément individuellement (par exemple, pour gérer les valeurs NaN différemment) :
df['description'] = df['description'].apply(lambda x: str(x) if pd.notnull(x) else '')

# Create a translator object
translator = Translator()


# Define the number of retries
max_retries = 5

# Translate the values in column H from Dutch to French
for i in range(len(df)):
    for j in range(max_retries):
        try:
            df.at[i, 'Translation'] = translator.translate(df.at[i, 'description'], src='nl', dest='fr').text
            print("Translated row " + str(i))
            break
        except ReadTimeout:
            print("ReadTimeout occurred. Waiting for 5 seconds before retrying...")
            time.sleep(20)  # pause for 8 seconds
    else:
        print("Failed to translate row " + str(i) + " after " + str(max_retries) + " attempts.")
# Save the translated values in a new Excel file
df.to_excel('3TradFRVegana.xlsx', index=False)


Any suggestions ?

I need to translate 1500 rows in an excel file, how to do it (maybe with an other solution?)