Given a string array of; Birds()
And a string of:
myString= “owl, robin, cardinal, hawk, chickadee”
What is the most elegant way to populate the array with the birds in the csv string?
Given a string array of; Birds()
And a string of:
myString= “owl, robin, cardinal, hawk, chickadee”
What is the most elegant way to populate the array with the birds in the csv string?
birds = Split( myString, ", " )
But I’d be surprised if there really is a space after the commas. At any rate, Split
is what you’re looking for.
Just to be complete, conversely,
myString = Join( birds, ", " )
You may want to cover quotes in the CSV.
For that I put a day of work long ago into a function SplitCommaSeparatedValuesMBS which does that including a lot of edge cases. (part of MBS Util plugin)
well since we’re all piling on you can have the code I wrote years ago for parsing csv files (and whatever else you find there)