csv:from-row
csv:from-row string csv:from-row string delimiter
Parses the given string as though it were a row from a CSV file and returns it as a list of values. For example:
observer> show csv:from-row "one,two,three"
observer: ["one" "two" "three"]
Quotes can be used when items contain commas:
observer> show csv:from-row "there's,a,comma,\"in,here\""
observer: ["there's" "a" "comma" "in,here"]
You can put two quotes in a row to put an actual quote in an entry. If the entry is not quoted, you can just use one quote:
observer> foreach (csv:from-row "he said \"hi there\",\"afterwards, she said \"\"hello\"\"\"") print
he said "hi there"
afterwards, she said "hello"
Number-like-entries will be parsed as numbers:
observer> show csv:from-row "1,-2.5,1e3"
observer: [1 -2.5 1000]
true
and false
with any capitalization will be parsed as booleans:
observer> show csv:from-row "true,TRUE,False,falsE"
observer: [true true false false]
To use a different delimiter, you can specify a second, optional argument. Only single character delimiters are supported:
observer> show (csv:from-row "1;2;3" ";")
observer: [1 2 3]
Different types of values can be mixed freely:
observer> show csv:from-row "one,2,true"
observer: ["one" 2 true]
Take me to the full CSV Extension Dictionary