4 ms·
My most popular stackoverflow answer [1] includes a CSV writer and reader. Yeah, I'd clean it up a little if I were doing it now (return enumerator instead of
by gavinpc 12y ago
My most popular stackoverflow answer [1] includes a CSV writer and reader. Yeah, I'd clean it up a little if I were doing it now (return enumerator instead of array, etc). But people keep using it.
It uses regex lookaheads to deal with quoting, so it's not 100% portable. But it's only about one page.
As for the other things mentioned by the OP (BOM, encoding), those should be handled by the stream, and are not the provenance of CSV per se.
[1] http://stackoverflow.com/a/769713/4525 http://stackoverflow.com/a/769713/4525
- EvanPlaice 12y agoRegex lookaheads are more efficient because you're copying everything between terminal chars at once as opposed to one char at a time. Unnecessary string copy operations are what make the parser slow.