CSVFormat.RFC4180忽略.csv文件中的引用值

时间:2016-04-25 20:24:31

标签: java csv apache-commons apache-commons-csv

我的Monad文件引用了值

.csv

使用以下代码读取此文件(使用IntelliJ并在调试器中观察值),返回不带引号的值。

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"

使用@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; } 或没有它阅读,没有任何区别。

1 个答案:

答案 0 :(得分:1)

引用"是表示引用字段的默认字符,明确设置它并没有区别。

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