twitter-sentiment-analysis icon indicating copy to clipboard operation
twitter-sentiment-analysis copied to clipboard

ValueError: invalid literal for int() with base 10: 'label'

Open Mustyy opened this issue 6 years ago • 7 comments

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?

Mustyy avatar Sep 26 '18 15:09 Mustyy

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.

abdulfatir avatar Sep 26 '18 15:09 abdulfatir

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.

Mustyy avatar Sep 26 '18 15:09 Mustyy

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.

Mustyy avatar Sep 26 '18 17:09 Mustyy

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 ?

Kanzll avatar Nov 21 '18 00:11 Kanzll

In preprocess.py, for lines 71 and 107, change test_file=True

ArnabMallik avatar Apr 09 '19 03:04 ArnabMallik

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.

KunikaValecha avatar May 19 '19 04:05 KunikaValecha

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 :)

shry4ns avatar Jul 08 '19 17:07 shry4ns