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('"');
閱讀或沒有它,沒有區別。