I have .csv
file that has quoted values
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"
Reading this file with the following code (using IntelliJ and observing values in the debugger), returns values without quotes.
@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;
}
Reading with .withQuote('"');
or without it, makes no difference.
The quote "
is the default character to represent quoted fields, and setting it explicitly makes no difference.
Do you want to get the original quote characters? In this case try setting the quote to a character that doesn't occur in the text, such as .withQuote('\0');