While using weka csv loader it gives me error in setSource Function " cannot resolve setSource
import weka.core.Instances;
import weka.core.converters.CSVLoader;
import java.io.File;
@SpringBootApplication
public class Demo3Application {
public static void main(String[] args) {
SpringApplication.run(Demo3Application.class, args);
}
// Load CSV file
CSVLoader loader = new CSVLoader();
loader.setSource(new File("C:\\Users\\user\\IdeaProjects\\demo3\\testdata3.csv.csv"));
Instances data = loader.getDataSet();
}
In Java, any task/operation which is to be performed should be inside a function.
Below is the updated code.
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import weka.core.Instances;
import weka.core.converters.CSVLoader;
import java.io.File;
import java.io.IOException;
@SpringBootApplication
public class Demo3Application {
public static void main(String[] args) throws IOException {
SpringApplication.run(Demo3Application.class, args);
CSVLoader loader = new CSVLoader();
loader.setSource(new File("C:\\Users\\Caroline.Karam\\IdeaProjects\\demo3\\testdata3.csv.csv"));
Instances data = loader.getDataSet();
}
}