Timeline for Parsing a single CSV line into a list of strings
Current License: CC BY-SA 3.0
9 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Apr 21, 2015 at 7:41 | comment | added | Pimgd | Let us continue this discussion in chat. | |
Apr 21, 2015 at 7:41 | comment | added | Pimgd | No, this is a question and answers website, where not everybody has the expertise or state of mind to grasp every detail about a posted bit of code. The focus of this Q&A website is the reviewing of code. What you have posted is an alternative implementation for the asker's problem, based off the unfounded notion that it's simpler to treat a CSV as a long list of fields. That unfounded notion does have a basis - if you're reading a single line of CSV, why bother treating it as a full CSV - treat it as a list of fields instead - but that basis is left unstated. | |
Apr 20, 2015 at 22:55 | comment | added | WeaponsGrade | Like I said above, you can remove it. Supposedly, this is a forum for developers, who understand how to trivially change code! | |
Apr 20, 2015 at 21:26 | comment | added | Pimgd |
Except then you're still screwed due to the way your split function works.
|
|
Apr 20, 2015 at 20:53 | comment | added | WeaponsGrade |
It's trivial to add case ',': buf.append(','); i++; continue loop; to the escape-cases above.
|
|
Apr 20, 2015 at 20:31 | comment | added | Pimgd | Your implementation doesn't support the following: "Fields containing a comma must be escaped. (...) Unix style programs escape these values by inserting a single backslash character before each comma, i.e. a single cell with the text apples, carrots, and oranges becomes apples\, carrots\, and oranges." | |
Apr 20, 2015 at 19:43 | history | edited | WeaponsGrade | CC BY-SA 3.0 |
added 57 characters in body
|
Apr 20, 2015 at 19:22 | comment | added | WeaponsGrade |
I realise that in split() , it wasn't necessary to test to see if the input had any quotes; but that's the simple case and the naïve solution, so why not?
|
|
Apr 20, 2015 at 19:16 | history | answered | WeaponsGrade | CC BY-SA 3.0 |