2016-04-25 43 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');