I need to export a generic list to CSV. Obviously I could write my own, but would like to avoid this!
I am able to google and find a lot of CSV parsers, but not many writers. I have downloaded FileHelpers but it doesn't properly escape output.
For instance if a field is equal to
,,",,,
the output is simply:
,,",,,
For the field. I would expect:
",,"",,,"
correct?
Any suggestions, or should I just do it myself?
Check out RFC 4180. I had to write a XSL to convert XML to CSV and this made it very easy to know what the 'right' thing is to do.
http://tools.ietf.org/rfc/rfc4180.txt
FileHelpers will do what you ask with the FieldQuoted attribute on your field in the record mapping class.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With