jeudi 26 février 2015

Converting CSV to Arff in Java. Getting errors like java.io.IOException



I asked a question earlier about this, but when I resolved one problem, I ran into another.


I'm following the official guide from weka here: Weka Tutorial


Here are the errors I'm getting.



---Registering Weka Editors---
Trying to add database driver (JDBC): jdbc.idbDriver - Error, not in CLASSPATH?
Exception in thread "main" java.io.IOException: wrong number of values. Read 2, expected 1, read Token[EOL], line 4
at weka.core.converters.ConverterUtils.errms(ConverterUtils.java:912)
at weka.core.converters.CSVLoader.getInstance(CSVLoader.java:824)
at weka.core.converters.CSVLoader.getDataSet(CSVLoader.java:646)
at arffBBALL.main(arffBBALL.java:15


I'm just trying to convert my CSV file to .arff


My CSV file looks like this.



Name,points,rebounds,steals,assists
Lebron James,17,10,1,7
Lebron James,29,5,2,8
Lebron James,30,4,0,8
Lebron James,24,4,1,3
Lebron James,25,1,0,11
Lebron James,22,4,2,9
Lebron James,21,3,2,2
Lebron James,27,7,1,14
Lebron James,41,5,0,5
Lebron James,35,2,2,2
Lebron James,18,4,3,4


Here's my Java file that's meant to convert the CSV file to .arff



import weka.core.Instances;
import weka.core.converters.CSVLoader;
import weka.core.converters.ArffSaver;
import java.io.File;

public class arffBBALL{
public static void main(String[] args) throws Exception{




//load CSV
CSVLoader loader = new CSVLoader();
loader.setSource(new File("/Users/myname/Desktop/bball.csv"));
Instances data = loader.getDataSet();


//save ARFF
ArffSaver saver = new ArffSaver();
saver.setInstances(data); // set the dataset we want to convert
// save as ARFF
saver.setFile(new File("/Users/myname/Desktop/nbball.csv"));
saver.writeBatch();
}
}


Whenever I try this, it seems like the Java Applet starts to load, then it gives me these errors. For some reason, it keeps trying to load a database. That doesn't seem to be needed according to the research I did of others who ran into this error. Unfortunately, I'm having trouble editing/ commenting out a DatabaseUtil.props file this link suggests. Stack Link


I'm at a loss. Anyone know what the errors mean and how I can fix them?


Any help would be appreciated.




Aucun commentaire:

Enregistrer un commentaire