0
我有一个CSV以下信息文件:拆分信息,算上串并丢弃重复
2,Cars
5,Cars
5,Planes
5,Boats
10,Planes
10,Boats
28,Planes
我想这一数字从交通的类型划分。我怎样才能算出汽车+飞机+船的总数是'3'而不是'7'?
我使用下面的Java代码,别人提供分裂CSV:
try {
BufferedReader br2 = new BufferedReader(new FileReader("transport.csv"));
System.out.println("\nTESTING");
String sCurrentLine2;
java.util.HashMap<String, String>();
while ((sCurrentLine2 = br2.readLine()) != null) {
String[] information2 = sCurrentLine2.split(",");
String transCode = information2[1];
System.out.println(transCode);
}
} catch (IOException e) {
e.printStackTrace();
}
在阵列字符串转码=信息2 [1];当我更改为0时,它会给出数字,当我更改为1时给出名称。