You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are consuming files from a 3rd party system and I've noticed that we're getting BadDataFound messages because some of the records are not consistently escaped. For example:
,,,,,,Standard,,,,,"Natureflex 90NM 46.75"" Non-Metallized-to-Metallized film Non-Metallized side OUT 6"" Cores Rolls labeled with OD, Wt (lb), LF/roll, NM side identified.",,,,,N/A,FILM001,,,,,,,,46.75" x 90 Non-Metallic 90NM Film,,,,,,,3,N/A,,46.7500,,,,,Active,,,Pounds,None,None,,,,
In this case:
"Natureflex 90NM 46.75"" Non-Metallized-to-Metallized film Non-Metallized side OUT 6"" Cores Rolls labeled with OD, Wt (lb), LF/roll, NM side identified."
This is properly escaped because it contains commas in the description, and so the whole field is wrapped in double-quotes and any double-quotes within the field are escaped with more double-quotes.
However:
46.75" x 90 Non-Metallic 90NM Film
This field is not properly escaped. The double-quote is tricking CsvHelper into thinking there's another special character coming, but there isn't. Hence, we get a BadDataFound on these types of records.
I've tried using the following to handle the situation but none occur earlier enough in the workflow to be effective:
EscapedTextConverter to add missing double-quote into the field
ReadingExceptionOccurred to change the RawRecord to include the missing double-quote (doesn't work because RawRecord is read-only)
Any other thoughts on how to handle this situation?
The record parses as expected but I'd prefer to avoid setting the BadDataFound event to null so it's still available to message me in case we truly do get bad data.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
We are consuming files from a 3rd party system and I've noticed that we're getting
BadDataFound
messages because some of the records are not consistently escaped. For example:In this case:
This is properly escaped because it contains commas in the description, and so the whole field is wrapped in double-quotes and any double-quotes within the field are escaped with more double-quotes.
However:
This field is not properly escaped. The double-quote is tricking CsvHelper into thinking there's another special character coming, but there isn't. Hence, we get a
BadDataFound
on these types of records.I've tried using the following to handle the situation but none occur earlier enough in the workflow to be effective:
Any other thoughts on how to handle this situation?
The record parses as expected but I'd prefer to avoid setting the
BadDataFound
event to null so it's still available to message me in case we truly do get bad data.Thanks!
Beta Was this translation helpful? Give feedback.
All reactions