ocaml-csv
ocaml-csv copied to clipboard
delimiter in field?
I seem to be having inconsistent output and it seems to be because in my CSV file, I have (single quoted) string fields that have the delimiter inside them. So:
'foo','bar','foo,bar'
Can this be handled in some way?
Single quotes are not valid CSV delimiters:
# Csv.input_all (Csv.of_string {|'foo','bar','foo,bar'|});;
- : Csv.t = [["'foo'"; "'bar'"; "'foo"; "bar'"]]
# Csv.input_all (Csv.of_string {|"foo","bar","foo,bar"|});;
- : Csv.t = [["foo"; "bar"; "foo,bar"]]
The single quotes are not the delimiter, a comma is. The single quotes are wrapping fields which can have a comma in them.
Sorry, I expressed badly. Single quotes cannot be used to enclose fields, only double quotes can.