Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.File;
- import java.io.FileNotFoundException;
- import java.util.Scanner;
- import weka.core.Instances;
- import weka.core.converters.ArffSaver;
- import weka.core.converters.CSVLoader;
- public class Coursework {
- public static void main(String[] args) throws FileNotFoundException {
- //Convert a CSV file to ARFF format
- //load the csv file
- try {
- CSVLoader loader = new CSVLoader();
- loader.setSource(new File("./new.csv"));
- Instances data = loader.getDataSet();
- //save an arff file
- ArffSaver saver = new ArffSaver();
- saver.setInstances(data);
- saver.setFile(new File("./new.arff"));
- saver.setDestination(new File("./new.arff"));
- saver.writeBatch();
- } catch (Exception e) {
- e.printStackTrace();
- }
- // Scanner scanner = new Scanner(new File("./pre-processed.csv"));
- // scanner.useDelimiter(",");
- // while (scanner.hasNext()) {
- // System.out.print(scanner.next() + "|");
- // }
- // scanner.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement