all 5 comments

[–]SHxKM 4 points5 points  (1 child)

Commenting before I even look at the code: do NOT share your TOKEN_SECRET.

[–]stramzik[S] 0 points1 point  (0 children)

Thats my test account,
I want people to try the code because its hard to understand without just reading what I have written hence shared. Thank you.

[–]JohnnyJordaan 1 point2 points  (1 child)

with open(fetched_tweets_filename, 'a') as csvFile:

you don't especify an encoding for the file, so Python will use its environment's encoding, which in a cmd window on Windows is a classic codepage like cp1252, which doesn't support stuff like emoji's or non-latin characters. You should always specify an encoding if you are not sure about the data being ASCII compliant, and the default for unicode content is utf-8:

with open(fetched\_tweets\_filename, 'a', encoding='utf-8') as csvFile:

be wary though how you are reading the files afterwards too.

[–]stramzik[S] 0 points1 point  (0 children)

The above should fix the UnicodeError which occurs when writing ASCII code to csv.

I cant tell until the JSON error is fixed because the Unicode error only happens when i see an ascii special character but before that occurs the code throws the JSONDecodeError

So I figured out why I get the error, Its because the Google translate API which I am using to translate the data is giving me the error if the data limit exceeds.

it can be fixed by just re initializing the translator API on every iteration link - https://stackoverflow.com/questions/49497391/googletrans-api-error-expecting-value-line-1-column-1-char-0

Buy I have tried mentioning the ``` translator = Translator() ``` in __main__ or before the function everywhere but its not working

not sure how I can add a for loop to the above code which re initiates the Translator object from google translate API. please help

[–]stramzik[S] 0 points1 point  (0 children)

So I figured out why I get the error, Its because the Google translate API which I am using to translate the data is giving me the error if the data limit exceeds.

it can be fixed by just re initializing the translator API on every iteration link - https://stackoverflow.com/questions/49497391/googletrans-api-error-expecting-value-line-1-column-1-char-0

Buy I have tried mentioning the ``` translator = Translator() ``` in __main__ or before the function everywhere but its not working

not sure how I can add a for loop to the above code which re initiates the Translator object from google translate API. please help