我想让DataModel包含许多* .csv文件。(这些文件具有相同的格式,不同的数据)
但是,我不知道该怎么做。
我无法通过mahout文档找到函数。(mahout-API)
“将大量* .csv文件制作成一个* .csv文件的模块”只有解决方案吗?
请帮助......!
答案 0 :(得分:0)
您可以将所有人* .csv文件合并,即合并两个文件,如下所示
public static void main(String [] args) throws IOException{
BufferedReader reader = new BufferedReader(new FileReader("YOUR_SOURCE_1"));
BufferedReader reader2 = new BufferedReader(new FileReader("YOUR_SOURCE_2"));
BufferedWriter writer = new BufferedWriter(new FileWriter("YOUR_TARGET");
int x = 0;
while ((line = reader.readLine()) != null) {
if (x > 0) {
String [] values = line.split("\\t", -1);
writer.write(values[0] + "," + values[1]+","+values[2]+"\n");
}
x++;
}
String line;
int x = 0;
while ((line = reader.readLine()) != null) {
if (x > 0) {
String [] values = line.split("\\t", -1);
writer.write(values[0] + "," + values[1]+","+values[2]+"\n");
}
x++;
}
reader.close();
reader2.close();
writer.close();
}