twitter-sentiment-analysis
twitter-sentiment-analysis copied to clipboard
ValueError: invalid literal for int() with base 10: 'label'
Preprocessing still doesn't happen since there is an error in this line: positive = int(line[:line.find(',')])
Here is the warning I get: ValueError: invalid literal for int() with base 10: 'label'
I looked up how to fix this and it looks like the string cannot be converted to int, so I tried int(float(...)) but didn't work
Any ideas?
Why would you try int(float(...))
?
Anyway, looks like your CSV headers are the cause of the problem. Remove the column names from the CSV or modify the code to skip that line.
I’ll try to remove the column headers
Best, Mustafa
On Sep 26, 2018, at 11:37 AM, Abdul Fatir [email protected] wrote:
Why would you try int(float(...))? Anyway, looks like your CSV headers are the cause of the problem. Remove the column names from the CSV or modify the code to skip that line.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
I removed the headers but it still doesn’t work as well. Any ideas why? All the packages are installed too Mustafa
On Sep 26, 2018, at 11:37 AM, Abdul Fatir [email protected] wrote:
Why would you try int(float(...))? Anyway, looks like your CSV headers are the cause of the problem. Remove the column names from the CSV or modify the code to skip that line.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
Why would you try
int(float(...))
? Anyway, looks like your CSV headers are the cause of the problem. Remove the column names from the CSV or modify the code to skip that line.
Hi @abdulfatir and thank you for you sharing,
I was able make the Preprocessing with train.csv with his 3 columns, but I got the same error although I remove the column names from test.csv , I think script process the data in the same way, how script can make the difference between train and test files ?
In preprocess.py, for lines 71 and 107, change test_file=True
Preprocessing still doesn't happen since there is an error in this line: positive = int(line[:line.find(',')])
Here is the warning I get: ValueError: invalid literal for int() with base 10: 'label'
I looked up how to fix this and it looks like the string cannot be converted to int, so I tried int(float(...)) but didn't work
Any ideas?
Recheck the columns in your csv file. It might have the sentiment placed at some some another index. e.g. - instead of tweet_id, sentiment, tweet , it could be tweet_id, tweet, sentiment or sth similar. Either change the index of code. or change the place of column in csv itself by cutting and copying the content of it just next to tweet_id.
I had the same error, but it was an issue with my csv headers. Anyway, thanks for the great library Abdul! I found it very helpful :)