【发布时间】:2014-03-05 06:05:59
【问题描述】:
我有以下代码可以从 android 中的 csv 文件中读取。当我的列值中有逗号时,它可以正常工作。
File file = new File(IMPORT_ITEM_FILE.getPath());
BufferedReader bufRdr = null;
try {
bufRdr = new BufferedReader(new FileReader(file));
} catch (FileNotFoundException e) {
}
String line = null;
try {
while ((line = bufRdr.readLine()) != null) {
String[] insertValues = line.split(",");
string column1 = insertValues[1];
string column2 = insertValues[2];
}
bufRdr.close();
}
我的 csv 行是这样的:用户名 ,"some string, with commas","2740740, 2740608",,"some, string, with commas"
如何转义列值中的逗号以读取列。
【问题讨论】: