【问题标题】:Weka - issue with line X ... coverting csv to ARFFWeka - X线的问题......将csv转换为ARFF
【发布时间】:2020-09-14 17:15:10
【问题描述】:

我目前正在尝试将信息的 csv 文件转换为 Weka 中的 ARFF 文件...

弹出的问题是第 3384 行有问题...但我看不出这行有什么问题?

Image of excel file here

有人可以帮忙吗?

谢谢。

【问题讨论】:

    标签: csv weka data-mining arff mining


    【解决方案1】:

    当要转换的文件中有非法字符时,经常会弹出这个问题。您可以仔细检查这些字符。您也可以使用下面的代码在java中进行从csv到arff的转换。

    import weka.core.Instances;
    import weka.core.converters.ArffSaver;
    import weka.core.converters.CSVLoader;
    
    import java.io.File;
    
    public class CsvtoArff {
      public static void main(String[] args) throws Exception {
    
        String args0="/Users/Kehinde/Documents/trainingtest.csv";
        String args1="/Users/Kehinde/Documents/theoutput.arff";
    
        // This is used to load CSV
        CSVLoader myloader = new CSVLoader();
        myloader.setSource(new File(args0));
        Instances mydata = myloader.getDataSet();
        System.out.println(mydata);
    
        // This is used to save ARFF
        ArffSaver mysaver = new ArffSaver();
        mysaver.setInstances(mydata);
        mysaver.setFile(new File(args1));
        mysaver.setDestination(new File(args1));
        mysaver.writeBatch();
      } 
    }
    

    【讨论】:

      猜你喜欢
      • 2012-05-07
      • 1970-01-01
      • 1970-01-01
      • 2015-05-21
      • 2015-05-20
      • 2017-11-24
      • 1970-01-01
      • 2015-11-20
      • 2011-03-31
      相关资源
      最近更新 更多