【发布时间】:2017-10-14 21:10:06
【问题描述】:
我有一个从文件中解析的 CSVRecords 列表:
https://drive.google.com/file/d/0ByASC8p2MeUKZlhTdkxETXV2U3M/view?usp=sharing
使用以下代码:
public static List<CSVRecord> getRecords(File file) throws Exception {
Reader in = new FileReader(file);
CSVParser parser = new CSVParser(in, CSVFormat.RFC4180);
List<CSVRecord> records = parser.getRecords();
parser.close();
records.remove(0);
return records;
}
其中一列是 p(pft),我正在尝试删除 p(pft) 小于 75 的所有记录: (optStratCsv 是 csvRecords 的列表)
for (int i = 0; i < optStratCsv.size(); i++) {
if (Integer.parseInt(optStratCsv.get(i).get(14)) < 75) {
optStratCsv.remove(i);
}
}
但是,虽然它应该给我一个大约 6000 条记录的列表,但它给了我一个大约 9000 条记录的列表,所以很明显我做错了什么。我想弄清楚我做错了什么。 干杯。
【问题讨论】: