I want convert the .csv file to .arff file
can someone suggest what to do?
my code is:
package csvtoarff;
import java.io.File;
import weka.core.Instances;
import weka.core.converters.ArffSaver;
import weka.core.converters.CSVLoader;
public class CsvToArff {
public static void main(String[] args) {
try{
String f1 = "C://Users//user//Desktop//testfold//test.csv";
String f2 = "C://Users//user//Desktop//testfold//output.arff";
// load the CSV file (input file)
CSVLoader loader = new CSVLoader();
loader.setSource(new File(f1));
String [] options = new String[1];
options[0]="-H";
loader.setOptions(options);
Instances data = loader.getDataSet();
System.out.println(data);
// save as an ARFF (output file)
ArffSaver saver = new ArffSaver();
saver.setInstances(data);
saver.setFile(new File(f2));
saver.writeBatch();
}
catch(Exception e){
}
}