gpt4 book ai didi

java - csv 到 arff 转换

转载 作者:行者123 更新时间:2023-12-01 14:09:55 24 4
gpt4 key购买 nike

我是java初学者,我想将现有的.csv文件转换为.arff文件,我已经编写了下面的代码,但它没有转换,而是出现了错误。请任何人帮助我解决这些错误并建议我如何 程序:

import weka.core.Instances;
import weka.core.converters.ArffSaver;
import weka.core.converters.CSVLoader;

import java.io.File;
import java.io.IOException;

public class meena {
/**
* takes 2 arguments:
* - CSV input file
* - ARFF output file
*/
public static void main(String[] args) throws IOException {

String args0="C:\\Documents and Settings\\CORI\\My Documents\\NetBeansProjects\\trainingset\\build\\classes\\svmlearn\\in.csv ";
String args1="C:\\Documents and Settings\\CORI\\My Documents\\NetBeansProjects\\trainingset\\build\\classes\\svmlearn\\output1.txt";
// load CSV
CSVLoader loader = new CSVLoader();
loader.setSource(new File(args0));
Instances data = loader.getDataSet();

// save ARFF
ArffSaver saver = new ArffSaver();
saver.setInstances(data);
saver.setFile(new File(args[1]));
saver.setDestination(new File(args[1]));
saver.writeBatch();
}
}



I am getting the below error:
---Registering Weka Editors---
Trying to add database driver (JDBC): RmiJdbc.RJDriver - Error, not in CLASSPATH?
Trying to add database driver (JDBC): jdbc.idbDriver - Error, not in CLASSPATH?
Trying to add database driver (JDBC): com.mckoi.JDBCDriver - Error, not in CLASSPATH?
Trying to add database driver (JDBC): org.hsqldb.jdbcDriver - Error, not in CLASSPATH?
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1
at meena.main(meena.java:26)
Java Result: 1

Please help me to convert .csv file into .arff file by suggesting me clearly how and where to pass the input

最佳答案

这里有两点。

  1. 在第 26 行,当我相信您打算使用 args1 时,您使用了 args[1]。
  2. 尝试添加数据库驱动程序 (JDBC) 不会阻止您的代码成功运行。

关于java - csv 到 arff 转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18606820/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com