I thought this will be trivial but I can’t get this to work.
Assume a line in a CSV file:
"Barack Obama", 48, "President", "1600 Penn Ave, Washington DC"
string[] tokens = line.split(',')
I expect this:
"Barack Obama"
48
"President"
"1600 Penn Ave, Washington DC"
but the last token is
'Washington DC' not
"1600 Penn Ave, Washington DC".
Is there an easy way to get the split function to ignore the comma within quotes?
I have no control over the CSV file and it doesn;t get sent to me. Customer A will be using the app to read files provided by an external individual.
You might have to write your own split function.
"character, toggle a booleanHere’s an example:
Then just call:
Benchmarks
Results of benchmarking my code and Dan Tao’s code are below. I’m happy to benchmark any other solutions if people want them?
Code:
Output: