Closed kou closed 2 years ago
:+1:
For example,
str = <<~CSV
"serial","value"
"108",11
"109",12
"10A",13
"10B",14
CSV
CSV.parse(str, converters: [:numeric])
# =>
[["serial", "value"], [108, 11], [109, 12], ["10A", 13], ["10B", 14]]
I want to preserve quoted numeric values "108", "109", but there are no means to do this in converter.
Some CSV writers use quote with special meaning. For example, R's
write.csv
use quote for string value or factor value.https://www.rdocumentation.org/packages/utils/versions/3.6.2/topics/write.table
The current CSV parser doesn't provide quoted information to field converter. If field convert knows whether the target value is quoted or not, it can process the target value as a factor value.
See also: https://github.com/red-data-tools/red-datasets/pull/140#issuecomment-1164855481