CSV conversion for .NET

I am looking for code or a component that will handle most of the different types of CSV files, like imbedded commas in a field.

Here are some of the conversions I have tried that did NOT work:

- .NET String.Split - will not handle imbedded commas
- OLEDB - sometimes thinks strings with numbers are numeric and removes leading zeros
- Lumneworks from CodeProject - exceptions too often and errors are difficult to understand
- FileHelpers - too much code to make it work

Thanks for any ideas
Tom SageAsked:
Who is Participating?
 
Mike TomlinsonConnect With a Mentor Middle School Assistant TeacherCommented:
0
 
nepaluzCommented:
seems straight foward, however I have to take your search for a solution as indication it may not be that simple....

Could you post a sample of the file you are trying to read? To my understanding, setting a streamreader's property to "has fields enclosedin quotes" should cover your scenario. Fields with commas in a CSV file are "usually" enclosed in double quotes.

So please, provise a sample ofthe file to take it foward?
0
 
Tom SageAuthor Commented:
Thanks for your reply.

The typical CSV has all the field quoted:  "Some Text","123456",...

Some CSV do not have quoted numbers:   "Some text",123456,...

Some CSV have imbedded commas:   "Some text","123,456",...

The first example is easy, but I get files from many different sources, so I never know what is next.  That is why I am looking for some robust code, or component.

Thanks
0
 
Tom SageAuthor Commented:
I think I  have tried TextFieldParser, and it would not handle the case where text is quoted, but numerics are not quoted.

I will try a quick test to see.

Thanks
0
 
Tom SageAuthor Commented:
TextFieldParser seems to work well on some test files.  I will have to do more testing to be sure.  In the meantime, I will assign the points and thank you for your prompt response.

Thanks !
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.