Python Google translate error while translating text, ConnectionError:...
up vote
0
down vote
favorite
I want to convert bunch of sentences from Vietnamese to English saved in excel file. I have around 200 sentences. I have latest version of urllib3
. Even if I keep just 10 sentences and run a code below I get following error. Is there any limit to number of sentences I can translate at a time?
Error:
ConnectionError: HTTPSConnectionPool(host='translate.google.com', port=443): Max retries exceeded with url: / (Caused by NewConnectionError(': Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond',))
Code:
from googletrans import Translator
import pandas as pd
import numpy as np
import time
import math
translator = Translator()
data=pd.read_excel('C:TextAnalyticsVietnamese to english.xlsx',dtype=object)
data.to_csv('data_temp.csv')
unique_data=pd.DataFrame(data['Subreason'].value_counts()).reset_index()[['index']]
unique_data['Translations']=''
for i in range(len(unique_data)):
temp=(unique_data['index'].iloc[i])
if(type(temp)==str):
print(temp)
a=translator.translate(temp,src='vi',dest='en')
unique_data['Translations'].iloc[i]=a.text
print(a.text)
if(i%20==0):
time.sleep(5)
print(i)
else:
time.sleep(1)
if(i>20000):
break
translate_dict=unique_data.set_index('index').to_dict().get('Translations')
data['Google_Translate']=data.REWORK_DESCRIPTION.map(translate_dict)
data.drop('Converted',inplace=True,axis=1)
path=r'data mv table.xls'
writer = pd.ExcelWriter(path, engine='openpyxl')
data.to_excel(writer, 'Translated', index=False)
writer.save()
python google-translate google-translation-api
add a comment |
up vote
0
down vote
favorite
I want to convert bunch of sentences from Vietnamese to English saved in excel file. I have around 200 sentences. I have latest version of urllib3
. Even if I keep just 10 sentences and run a code below I get following error. Is there any limit to number of sentences I can translate at a time?
Error:
ConnectionError: HTTPSConnectionPool(host='translate.google.com', port=443): Max retries exceeded with url: / (Caused by NewConnectionError(': Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond',))
Code:
from googletrans import Translator
import pandas as pd
import numpy as np
import time
import math
translator = Translator()
data=pd.read_excel('C:TextAnalyticsVietnamese to english.xlsx',dtype=object)
data.to_csv('data_temp.csv')
unique_data=pd.DataFrame(data['Subreason'].value_counts()).reset_index()[['index']]
unique_data['Translations']=''
for i in range(len(unique_data)):
temp=(unique_data['index'].iloc[i])
if(type(temp)==str):
print(temp)
a=translator.translate(temp,src='vi',dest='en')
unique_data['Translations'].iloc[i]=a.text
print(a.text)
if(i%20==0):
time.sleep(5)
print(i)
else:
time.sleep(1)
if(i>20000):
break
translate_dict=unique_data.set_index('index').to_dict().get('Translations')
data['Google_Translate']=data.REWORK_DESCRIPTION.map(translate_dict)
data.drop('Converted',inplace=True,axis=1)
path=r'data mv table.xls'
writer = pd.ExcelWriter(path, engine='openpyxl')
data.to_excel(writer, 'Translated', index=False)
writer.save()
python google-translate google-translation-api
which library are you using? it doesn't seems the latest Translate API version. check this link: cloud.google.com/translate/docs/… And also this is the last API version: github.com/googleapis/google-cloud-python/tree/master/translate
– Alex Riquelme
Nov 21 at 14:57
@AlexRiquelme: I am usinggoogletrans
. Is it mandatory to create billing account to use Google Translate API. I am new to this Google Translate API.
– Aditi
Nov 22 at 8:21
Sorry, I can't help with that, I don't know anything about "googletrans"
– Alex Riquelme
Nov 22 at 16:19
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I want to convert bunch of sentences from Vietnamese to English saved in excel file. I have around 200 sentences. I have latest version of urllib3
. Even if I keep just 10 sentences and run a code below I get following error. Is there any limit to number of sentences I can translate at a time?
Error:
ConnectionError: HTTPSConnectionPool(host='translate.google.com', port=443): Max retries exceeded with url: / (Caused by NewConnectionError(': Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond',))
Code:
from googletrans import Translator
import pandas as pd
import numpy as np
import time
import math
translator = Translator()
data=pd.read_excel('C:TextAnalyticsVietnamese to english.xlsx',dtype=object)
data.to_csv('data_temp.csv')
unique_data=pd.DataFrame(data['Subreason'].value_counts()).reset_index()[['index']]
unique_data['Translations']=''
for i in range(len(unique_data)):
temp=(unique_data['index'].iloc[i])
if(type(temp)==str):
print(temp)
a=translator.translate(temp,src='vi',dest='en')
unique_data['Translations'].iloc[i]=a.text
print(a.text)
if(i%20==0):
time.sleep(5)
print(i)
else:
time.sleep(1)
if(i>20000):
break
translate_dict=unique_data.set_index('index').to_dict().get('Translations')
data['Google_Translate']=data.REWORK_DESCRIPTION.map(translate_dict)
data.drop('Converted',inplace=True,axis=1)
path=r'data mv table.xls'
writer = pd.ExcelWriter(path, engine='openpyxl')
data.to_excel(writer, 'Translated', index=False)
writer.save()
python google-translate google-translation-api
I want to convert bunch of sentences from Vietnamese to English saved in excel file. I have around 200 sentences. I have latest version of urllib3
. Even if I keep just 10 sentences and run a code below I get following error. Is there any limit to number of sentences I can translate at a time?
Error:
ConnectionError: HTTPSConnectionPool(host='translate.google.com', port=443): Max retries exceeded with url: / (Caused by NewConnectionError(': Failed to establish a new connection: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond',))
Code:
from googletrans import Translator
import pandas as pd
import numpy as np
import time
import math
translator = Translator()
data=pd.read_excel('C:TextAnalyticsVietnamese to english.xlsx',dtype=object)
data.to_csv('data_temp.csv')
unique_data=pd.DataFrame(data['Subreason'].value_counts()).reset_index()[['index']]
unique_data['Translations']=''
for i in range(len(unique_data)):
temp=(unique_data['index'].iloc[i])
if(type(temp)==str):
print(temp)
a=translator.translate(temp,src='vi',dest='en')
unique_data['Translations'].iloc[i]=a.text
print(a.text)
if(i%20==0):
time.sleep(5)
print(i)
else:
time.sleep(1)
if(i>20000):
break
translate_dict=unique_data.set_index('index').to_dict().get('Translations')
data['Google_Translate']=data.REWORK_DESCRIPTION.map(translate_dict)
data.drop('Converted',inplace=True,axis=1)
path=r'data mv table.xls'
writer = pd.ExcelWriter(path, engine='openpyxl')
data.to_excel(writer, 'Translated', index=False)
writer.save()
python google-translate google-translation-api
python google-translate google-translation-api
asked Nov 21 at 5:33
Aditi
680721
680721
which library are you using? it doesn't seems the latest Translate API version. check this link: cloud.google.com/translate/docs/… And also this is the last API version: github.com/googleapis/google-cloud-python/tree/master/translate
– Alex Riquelme
Nov 21 at 14:57
@AlexRiquelme: I am usinggoogletrans
. Is it mandatory to create billing account to use Google Translate API. I am new to this Google Translate API.
– Aditi
Nov 22 at 8:21
Sorry, I can't help with that, I don't know anything about "googletrans"
– Alex Riquelme
Nov 22 at 16:19
add a comment |
which library are you using? it doesn't seems the latest Translate API version. check this link: cloud.google.com/translate/docs/… And also this is the last API version: github.com/googleapis/google-cloud-python/tree/master/translate
– Alex Riquelme
Nov 21 at 14:57
@AlexRiquelme: I am usinggoogletrans
. Is it mandatory to create billing account to use Google Translate API. I am new to this Google Translate API.
– Aditi
Nov 22 at 8:21
Sorry, I can't help with that, I don't know anything about "googletrans"
– Alex Riquelme
Nov 22 at 16:19
which library are you using? it doesn't seems the latest Translate API version. check this link: cloud.google.com/translate/docs/… And also this is the last API version: github.com/googleapis/google-cloud-python/tree/master/translate
– Alex Riquelme
Nov 21 at 14:57
which library are you using? it doesn't seems the latest Translate API version. check this link: cloud.google.com/translate/docs/… And also this is the last API version: github.com/googleapis/google-cloud-python/tree/master/translate
– Alex Riquelme
Nov 21 at 14:57
@AlexRiquelme: I am using
googletrans
. Is it mandatory to create billing account to use Google Translate API. I am new to this Google Translate API.– Aditi
Nov 22 at 8:21
@AlexRiquelme: I am using
googletrans
. Is it mandatory to create billing account to use Google Translate API. I am new to this Google Translate API.– Aditi
Nov 22 at 8:21
Sorry, I can't help with that, I don't know anything about "googletrans"
– Alex Riquelme
Nov 22 at 16:19
Sorry, I can't help with that, I don't know anything about "googletrans"
– Alex Riquelme
Nov 22 at 16:19
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53405792%2fpython-google-translate-error-while-translating-text-connectionerror-httpsconn%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
which library are you using? it doesn't seems the latest Translate API version. check this link: cloud.google.com/translate/docs/… And also this is the last API version: github.com/googleapis/google-cloud-python/tree/master/translate
– Alex Riquelme
Nov 21 at 14:57
@AlexRiquelme: I am using
googletrans
. Is it mandatory to create billing account to use Google Translate API. I am new to this Google Translate API.– Aditi
Nov 22 at 8:21
Sorry, I can't help with that, I don't know anything about "googletrans"
– Alex Riquelme
Nov 22 at 16:19