我想知道,我们是否可以在csv中搜索包含特定单词的特定行(就像我们在使用find的UI中所做的那样)。opencsv是否提供此功能?
如果不是,在csv文件中搜索的最佳方式是什么?
发布于 2013-06-04 20:53:16
不,它不需要,但您可以简单地遍历字段
CSVReader reader = new CSVReader(new FileReader("yourfile.csv"));
String [] nextLine;
String searchWord = ".*\\d+.*"; // field contains integer?
while ((nextLine = reader.readNext()) != null) {
for (String field: nextLine) {
if (field.matches(searchWord)) {
// matched word...
}
}
}https://stackoverflow.com/questions/16918195
复制相似问题