嗨,我正在尝试读取test.csv
以 JAVA 调用的 CSV 文件。下面是我的代码:
import java.io.BufferedReader;
import java.io.FileReader;
public class InsertValuesIntoTestDb {
@SuppressWarnings("rawtypes")
public static void main(String[] args) throws Exception {
String splitBy = ",";
BufferedReader br = new BufferedReader(new FileReader("test.csv"));
String line = br.readLine();
while(line!=null){
String[] b = line.split(splitBy);
System.out.println(b[0]);
}
br.close();
}
}
这是我的 CSV 文件(test.csv):
a,f,w,b,numinst,af,ub
1RW,800,64,22,1,48:2,true
1RW,800,16,39,1,48:2,true
1RW,800,640,330,1,48:2,true
1RW,800,40,124,1,48:2,true
1RW,800,32,104,1,48:2,true
1RW,800,8,104,1,48:2,true
1R1W,800,65536,39,1,96:96,true
1R1W,800,2048,39,1,96:96,true
1R1W,800,8192,39,1,48:48,true
我正在尝试打印 csv 中的第一列,但我得到的输出只是a
在无限循环中。谁能帮我修复此代码以打印整个第一列。谢谢。