Wrong number of values when importing csv in Weka - csv

I want to open a csv file (saved from openoffice calc) in weka.
I keep getting an error: "wrong number of values. 140 read, 139 expected on line 3."
The csv was already fixed with quotes around the labels. And I count 140 values on the first lines.
What is wrong here?
Link to the file.

Turns out there was an value somewhere for beyond sight in the excel file I was exporting.
I noticed it because all the rows ended with a comma instead of nothing.
Carefully selected only the right reach, copied in a document and works.
Hope this helps somebody else as well.

I had the same error.!!!! I found the solution.
Just remove all the double-quote, single-quote from the .csv, .xls file.
i,e for eg. under the Name column if the value is "john" it throws an error. Make it to john by removing the quotes.
To remove all the quotes, go to the excel file FInd and replace box.
Find what - "
Replace with - (empty space)

I also went through the same problem when I was using Weka and importing a csv file.
The problem is with the wrong formatting of the file
In my file there was a word in one of the columns GOV'T what I just did was removed the "'" and wrote a whole word GOVERNMENT and it worked.
Hope this helps !!

I had the same error. Problem was a sigle quote character in a string value. Solution for me was to eclose the whole string value in double quotes.
So I have to convert
this: ...,Uncharted 3: Drake's Deception,...
to this: ...,"Uncharted 3: Drake's Deception",...
using weka v. 3.8.0

This is because of addition of extra column. So to get rid of that error, select whole of that column and delete that column.
That should work fine. :)

I also encountered with that error. My csv file contains floating numbers. I have solved that problem by replacing "," with "." .

For me all of the above worked. I replaced " ' , with space.

I had the same error before. I changed my .xls files without any blank ranks. Sometimes the Weka loaded too many "," . But if I clear the blank ranks than the Weka could be work.

If you have copied data from another file using Conrol+A, Control+C and control+V, you copied extra columns. if you open csv file in Nodepad you will see comma in the end of each row. you got this error because of the comma in the end of each row.
To avoid this error, press Control and select columns one by one then Control+C now copy it to new File which you will use in weka.
or you can use another method to avoid comma in the end of each row.

I encountered the same problem.
Replacing/ erasing all " and ' with space worked for me!

Related

Why aren't my functions working as expected in MySQL?

I am trying to figure out why MYSQL isn't working as expected.
I imported my data from a CSV into a table called Products, which is shown in the screenshot. It's a small table of just ID and Name.
But when I run the where clause, finding out where the Name = 'SMS', it returns nothing? I don't understand what the issue is.
My CSV contents in Notepad++ is shown below:
This is what I used to load in my CSV, if there are any errors here.
Could you share your csv file content?
It's happened to me too before, and the problem is because there's some blank space in the data in csv file.
So maybe you could parse first your csv file data (remove the "not needed" blank space) before import it to database
This is often caused by spaces or look-alike characters. If caused by spaces or invisible characters at the beginning/end, you can try:
where name like '%SMS%'
You can then make this more general:
where name like '%S%M%S%'
When you get a match, you'll need to do more investigate to find the actual cause.

Why am I getting an unexpected Error in Snowflake PUT load?

I am trying to load a local csv file to my staging area in Snowflake, and am using:
PUT file:'//Users/mark 1/Downloads/pp-complete.csv' #~ auto_compress=true;
But I keep getting the error:
SQL compilation error: parse error line 1 at position 9 near '39'.
syntax error line 1 at position 74 unexpected '
As far as I can tell, there's nothing 'wrong' with the SCV file. It opens fine in SublimeEdit and Excel, and I can't see anything 'funny' in there to account for this.
Am stuck now.
Thanks,
Mark
PUT file://C:\\Users\\mark 1\\Downloads\\pp-complete.csv #~ auto_compress=true;
Above command worked, added snip for your reference. Instead of single quotes use double slash to escape your path. So change your put command as like below and try.
Could you try this?
PUT 'file:///Users/mark 1/Downloads/pp-complete.csv' #~ auto_compress=true;
I think you don't need single quotes, and an extra slash:
PUT 'file:///Users/mark 1/Downloads/pp-complete.csv' #~ auto_compress=true;
Refer to the examples here
EDIT: I realize you probably do need the quotes because of the space in your file name. but I think the issue is the missing slash

Weka csv to arff special characters caue error

I'm new to Weka and having problems converting a CSV file containing Tweets into an Arff file.
The CSV looks like this
Tweet,Class
Conference Update: 50% Off Registration to End .. http://t.co/nZtkSzZnJ6,Yes
When I try to convert to .arff using Explorer, I receive the following error
"...not recognized as an CSV data files Reason: wrong number of values. Read 1 expected 2, read token[EOF], line 2"
Removing the "%" character allows the file to convert to arff without error. I could remove "%" and other characters but I really don't want to alter my Tweet data. Enclosing in single or double quotes does not help either. Any idea what I am doing wrong?
Appreciate any help
Weka may interprete "%" as a begining of comment, and may ignore "%" and rest of that line.
Please enclose entire field ,which contains character "%", with quotation marks (both of single quote "'" and doubel quote '"' work well).
For Example:
A csv file which contents following two lines, may be able to convert to Arff file by Weka.
Tweet,Class
"Conference Update: 50% Off Registration to End .. http://t.co/nZtkSzZnJ6",Yes
P.S.
I'm sorry that my previous answer is incorrect.
PRIVIOUS ANSWER (Incorrect answer) was:
Try to replace "%" character to "\%".
"\" works as escape character, so "\" makes the comment-delimiter character "%" to a normal character "%".

Loading comma separated .csv file into database

I was trying to load a .csv file into my database. It was a comma delimited file and for one of the columns there is a comma(,) in between the data just like Texas,Houston can some one help me how to get rid of the comma in between. the package which i have created recognizing the value after the comma as a new column but it should not be like that. Can any of the guys help me in this. I was getting error in the Flat file source itself. I thought of using Derived column but the package is failing at the source point itself.
Well some "comma" delimited files have ,"something or other", when there is a string and only use ,numeric_value, when its a number type. If your file is like this then you can preprocess your file changing ," for some (other) rare character, and similarly ", then replace the , if it occurs between the two rare characters. Or you can count the comma in any line and if its greater than the number pf delimited columns, manually frocess the exceptions

How to assign a text qualifier in a flat file destination?

We have an SSIS package which reads from a DB, creates a flat file from that info, and drops it to a file server.
I recently made an update to the package's query which is used against the DB, adjusted the column mappings, and placed it under the SQL Job which ran the SSIS package before.
The problem is that the text qualifier in the flat file should be a quotation mark: ". But when I checked the flat file it produced, the text qualifier showing is: _x0022_
I investigated the Text Qualifier property for the DestinationConnectionFlatFile, and it is set to a quotation mark: "
How can I ensure the flat file will have a text qualifier of quotation mark?
Here is a previous answer I found when this happened to me:
SSIS exporting data to flat file renders double quotes as hexadecimal characters
Additionally ,
This issue occures because of installation issue. So if you see this sort of Issue, It mean if you are loading from file Database table and file contains 100 records , then instead of 100 records only 99 records would get loaded to database , last records would get skipped.
I had same issue, to fix that I had re-instalation of
1) MS Visual Studio
2) MS BI Studio
in the sequence mentioned above.
Given below are the two solutions :
Solution 1: Open the Package in Notepad and Edit the Value present in the "TextQualifier" of particular object to """.
object Name
"
Solution 2: open the Package and Replace the Value in the "TextQualifier" of the Flat File Connection Managers (FFD,SRC,SOURCE) to "\"".
Solution 1: Open the Package in Notepad and Edit the Value present in the "TextQualifier" of particular object to (") &quot follow semicolon
object Name
"
Thanks,
Prakash.A