1

VB2005. So just diong some testing and ran into this oddity while parsing my CSV data with the TextFieldParser http://connect.microsoft.com/VisualStudio/feedback/details/679596/textfieldparser-does-not-respect-consecutive-line-breaks-in-the-middle-of-a-field where it doesn't recognize repeated line breaks in a field. Note that this is not the same as skipping blank fields. Anyway, I am testing an alternative way to get the data. I am trying the plain old Split function but that function cant handle embedded commas in a field like the TextFieldParser can. Are there any workarounds to this issue?

As an example the source data field reads:

"this is line 1
this is line 2

this is line 3


this is line 4
this is line 5"

And after I parse it with the TextFieldParser I get an output:

this is line 1
this is line 2
this is line 3
this is line 4
this is line 5

Seemingly any blank line gets ignored. If I had a memo with several paragraphs in the field this would jumble it all together with no spacing between. Does any else see this behavior?

Update: Used the CSV reader from Code project http://www.codeproject.com/Articles/9258/A-Fast-CSV-Reader and it works great. Doesn't trim the inner line breaks on empty lines.

6
  • Does the data have multiple line breaks in a fields and do you need multiple line breaks in fields?
    – paparazzo
    Apr 15, 2013 at 1:02
  • Well yes and no. The application is for reading and converting the users data. If the user has a field that has multiple line feeds I have to assume that's what they want in the conversion. I made an update to my request.
    – sinDizzy
    Apr 15, 2013 at 1:07
  • How much more validation do you need? You have a problem report and you have repeated the behavior. The fix it to write your own parser. Correct split is not enough. Welcome to Regex.
    – paparazzo
    Apr 15, 2013 at 1:27
  • Probably on the same level as the TextFieldParser. The input data could be almost anything as long as it adheres to the CSV format with any fields with embedded quotes will be enclosed with quotes. I guess that's where I am an not really knowing how to continue.
    – sinDizzy
    Apr 15, 2013 at 5:09
  • SO is not a code generation tool. You need to start with a specific programming question.
    – paparazzo
    Apr 15, 2013 at 13:08

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.