/** * returns the loader used in the tests. * * @return the configured loader */ public AbstractLoader getLoader() { return new CSVLoader(); }
/** * Main method. * * @param args should contain the name of an input file. */ public static void main(String[] args) { runFileLoader(new CSVLoader(), args); }
/** * Main method. * * @param args should contain the name of an input file. */ public static void main(String[] args) { runFileLoader(new CSVLoader(), args); }
/** * returns the loader used in the tests. * * @return the configured loader */ public AbstractLoader getLoader() { return new CSVLoader(); }
// load CSV CSVLoader loader = new CSVLoader(); if(null != inputFile){ loader.setSource(inputFile); data = loader.getDataSet(); }else{ Log.e("ERROR","error the input file is null"); }
CSVLoader loader = new CSVLoader(); loader.setSource(new File(CSVFilePath)); String[] options = new String[1]; options[0] = "-H"; loader.setOptions(options); Instances data = loader.getDataSet();
} else if (f.getName().toLowerCase().endsWith(CSVLoader.FILE_EXTENSION)) { fileType = "csv"; CSVLoader cnv = new CSVLoader(); cnv.setSource(f); Instances inst = cnv.getDataSet();
import weka.core.Instances; import weka.core.converters.ArffSaver; import weka.core.converters.CSVLoader; import java.io.File; public class CsvArffConverter { public static void Convert(String sourcepath,String destpath) throws Exception { // load CSV CSVLoader loader = new CSVLoader(); loader.setSource(new File(sourcepath)); Instances data = loader.getDataSet(); // save ARFF BufferedWriter writer = new BufferedWriter(new FileWriter(destpath)); writer.write(dataSet.toString()); writer.flush(); writer.close(); } public static void main(String args[]) throws Exception { Convert("BSEIT.csv", "test.arff"); } }
CSVLoader loader = new CSVLoader(); loader.setSource(new File(args[0])); Instances data = loader.getDataSet();
} else if (f.getName().toLowerCase().endsWith(CSVLoader.FILE_EXTENSION)) { fileType = "csv"; CSVLoader cnv = new CSVLoader(); cnv.setSource(f); Instances inst = cnv.getDataSet();
/** * Method for testing the class from command line. * * @param args The supplied command line arguments. */ public static void main(String[] args) { if (args.length != 1) { System.err.println("Usage: CoverTree <ARFF file>"); System.exit(-1); } try { Instances insts = null; if (args[0].endsWith(".csv")) { CSVLoader csv = new CSVLoader(); csv.setFile(new File(args[0])); insts = csv.getDataSet(); } else { insts = new Instances(new BufferedReader(new FileReader(args[0]))); } CoverTree tree = new CoverTree(); tree.setInstances(insts); print("Created data tree:\n"); print(0, tree.m_Root); println(""); } catch (Exception ex) { ex.printStackTrace(); } } }
// load CSV CSVLoader loader = new CSVLoader(); String InputFilename = "TrainingFileName"; loader.setSource(new File(InputFilename)); Instances data = loader.getDataSet(); // save ARFF ArffSaver saver = new ArffSaver(); saver.setInstances(data); String FileT = Filename+".arff"; saver.setFile(new File(Path+Directory+"\\"+FileT)); saver.writeBatch();
/** * Method for testing the class from command line. * * @param args The supplied command line arguments. */ public static void main(String[] args) { if (args.length != 1) { System.err.println("Usage: CoverTree <ARFF file>"); System.exit(-1); } try { Instances insts = null; if (args[0].endsWith(".csv")) { CSVLoader csv = new CSVLoader(); csv.setFile(new File(args[0])); insts = csv.getDataSet(); } else { insts = new Instances(new BufferedReader(new FileReader(args[0]))); } CoverTree tree = new CoverTree(); tree.setInstances(insts); print("Created data tree:\n"); print(0, tree.m_Root); println(""); } catch (Exception ex) { ex.printStackTrace(); } } }
reader.close(); } else if (filepath.endsWith(".csv")) { // loading instances from csv file CSVLoader loader = new CSVLoader(); loader.setNoHeaderRowPresent(true); loader.setSource(new File(filepath));
/** * Load the mnist minimal meta arff file * * @return Mnist minimal meta data as Instances * @throws Exception IO error. */ public static Instances loadCSV(String path) throws Exception { CSVLoader csv = new CSVLoader(); csv.setSource(new File(path)); Instances data = csv.getDataSet(); data.setClassIndex(data.numAttributes() - 1); return data; }
/** * Pops up generic object editor with list of conversion filters * * @param f the File */ private void converterQuery(final File f) { final GenericObjectEditor convEd = new GenericObjectEditor(true); try { convEd.setClassType(weka.core.converters.Loader.class); convEd.setValue(new weka.core.converters.CSVLoader()); ((GenericObjectEditor.GOEPanel) convEd.getCustomEditor()) .addOkListener(new ActionListener() { public void actionPerformed(ActionEvent e) { tryConverter((Loader) convEd.getValue(), f); } }); } catch (Exception ex) { } PropertyDialog pd; if (PropertyDialog.getParentDialog(this) != null) pd = new PropertyDialog(PropertyDialog.getParentDialog(this), convEd, -1, -1); else pd = new PropertyDialog(PropertyDialog.getParentFrame(this), convEd, -1, -1); pd.setVisible(true); }
/** * Pops up generic object editor with list of conversion filters * * @param f the File */ private void converterQuery(final File f) { final GenericObjectEditor convEd = new GenericObjectEditor(true); try { convEd.setClassType(weka.core.converters.Loader.class); convEd.setValue(new weka.core.converters.CSVLoader()); ((GenericObjectEditor.GOEPanel) convEd.getCustomEditor()) .addOkListener(new ActionListener() { public void actionPerformed(ActionEvent e) { tryConverter((Loader) convEd.getValue(), f); } }); } catch (Exception ex) { } PropertyDialog pd; if (PropertyDialog.getParentDialog(this) != null) pd = new PropertyDialog(PropertyDialog.getParentDialog(this), convEd, -1, -1); else pd = new PropertyDialog(PropertyDialog.getParentFrame(this), convEd, -1, -1); pd.setVisible(true); }