2016-04-25 42 views
0

我已经.csv文件引述值CSVFormat.RFC4180忽略引述值.csv文件

Gender,ParentIncome,IQ,ParentEncouragement,CollegePlans 
"Male",53900,118,"Encouraged","Plans to attend" 
"Female",24900,87,"Not Encouraged","Does not plan to attend" 
"Female",65800,93,"Not Encouraged","Does not plan to attend" 

读取该文件与下面的代码(使用的是IntelliJ,并观察调试器值),返回值不包括引号。

@Override 
    public CsvConnectorService read(String fullFileName, String outputAddress, int intervalMs, boolean repeat, 
            Handler<AsyncResult<Void>> result) { 
     CSVFormat format = CSVFormat.RFC4180.withHeader().withIgnoreEmptyLines().withQuote('"'); 

     Subscription subscription = createCsvObservable(fullFileName, format, intervalMs, repeat) 
       .subscribeOn(Schedulers.io()) 
       .subscribe(record -> 

         eventBus.publish(outputAddress, convertRecordToJson(record))); 

     subscriptions.add(subscription); 

     result.handle(Future.succeededFuture()); 
     return this; 
    } 

.withQuote('"');阅读或没有它,没有区别。

回答

1

报价"是表示带引号的字段的默认字符,并且明确设置它没有区别。

你想得到原始的引用字符吗?在这种情况下,尝试将引号设置为文本中未出现的字符,例如.withQuote('\0');