Pages

Tuesday, May 29, 2012

Weka - Cannot open csv file saved from Excel

When saving or exporting a file from Excel as a Comma Separated (delineated) file .csv to open in Weka data mining Java based software a similar error will occur.

File 'C:\path to file\FileName.csv' not recognised as an 'CSV data files' file.
Reason:
wrong number of values. Read 6, expected 19, read Token[EOL], line 1987

Although your error message will have a different read, expected and or line number the issue may be caused by data in your file that includes a single quote or double quotes.

To fix this issue, simply do a find/replace of all single ' and double " quotation marks and then save the file as a .csv again.  When you open it into Weka it should now import/convert without errors.

You might also make note that Weka does not have data file size limitations.  It is however limited by the amount of memory you allocate to Java for it's use.  If you're working with very large data files you will want to increase the amount of memory allocated to Weka in the runweka.ini file.