我有一个CSV文件,我在解析时遇到问题.我正在使用opencsv库.这是我的数据看起来和我想要实现的目标.
RPT_PE,CLASS,RPT_MKT,PROV_CTRCT,CENTER_NM,GK_TY,MBR_NM,MBR_PID"20150801","NULL","33612","00083249P PCP602","JOE SMITH ARNP","NULL","FRANK,LUCAS E"," 50004655200"
我遇到的问题是成员名称("FRANK, LUCAS E"
)被分成两列,成员名称应该是一个.我再次使用opencsv和逗号作为分隔符.有什么方法可以忽略双引号内的逗号吗?
public void loadCSV(String csvFile, String tableName,
boolean truncateBeforeLoad) throws Exception {
CSVReader csvReader = null;
if (null == this.connection) {
throw new Exception("Not a valid connection.");
}
try {
csvReader = new CSVReader(new FileReader(csvFile), this.seprator);
} catch (Exception e) {
e.printStackTrace();
throw new Exception("Error occured while executing file. "
+ e.getMessage());
}
String[] headerRow = csvReader.readNext();
if (null == headerRow) {
throw new FileNotFoundException(
"No columns …
Run Code Online (Sandbox Code Playgroud)