Quoted values in csv and line feeds/carriage returns in the middle of values ? #2013
SqlBenjamin
started this conversation in
General
Replies: 1 comment 2 replies
-
That's not a valid CSV file. Check out the format from RFC 4180. https://www.rfc-editor.org/rfc/rfc4180 If you have an invalid format like that, there are some things you can try to still read it, but there isn't a way to know that a double quote in the middle of a field isn't then end of the field. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
So, I wrote my own code to parse csv I'm getting in memory (does not exist on disk anywhere) and then heard about this solution...however, I know I've had to handle line feeds and/or carriage returns in the middle of values (sometimes multiples) along with a couple other things and I'm not sure if CsvHelper handles that. For example, let's say I have the following:
"Column1","Column2","Column3"
"blah","hello","some other value"
"He said "what's up?"","this is a
multi line
value with a " in it","Josh,
this last column also has a line feed in it"
"value1","value2","value3"
Does CsvHelper properly get the 3 rows + 1 header row? It's comma delimited but values are between double quotes...but there can be quotes inside of the values as well as values with line feeds. If CsvHelper is easily capable of parsing this, is there some example I can see? (Where can I find some documentation/examples?)
I do see that there is also a CsvDataReader to load a datatable which is intereting because currently I use the header row in conjunction with a table definition - where the names match I use the type and nullable properties listed otherwise just use string and nullable values - to create a datatable, then populate that table with the rows. I doubt that class allows for that level of 'dynamic' but it would be pretty awesome if it does.
Thanks in advance for the answers/pointers.
Beta Was this translation helpful? Give feedback.
All reactions