Just realised this is an old(ish) post but it has had a recent response so I'll still add the below FWIW...
This is nice an simple but be aware it doesn't handle commas, or other potentially problematic characters, in a string value.
CSV requires that any value containing quotes or the delimiter (comma) should be quoted, anything that reads in CSV should handle this.
Given an example "one,2,three,4" your example works but """one,"",2,three,4" will not, it will create a list with 5 parts.
set line = """one,"",2,three,4"
set fields = $ListFromString(line, ",")
for n = 1:1:$listlength(fields) w !,$list(fields,n)
"one
"
2
three
4The %SQL.Util.Procedures class has some useful CSV methods or take a look at CSVGEN.
- Log in to post comments