tags:

views:

77

answers:

3

Hi,

I've looked at FileHelpers v2.0 but there is a serious problem woth that. I cannot define a class that maps to the record in the source/detination file.

The reason is I don't know what file I'm going to get. A big part of my program is mapping the file's fields to the database's fields... I don't know how many fields there wil be, nor wich will need to be imported.

I have no intention on rolling my own lib, especially since I have no control over the files that are going to be fed to my program.

Any solutions tot his?

Dennis

+2  A: 

Check out the Fast CSV reader on the CodeProject. It helped me with my project a while ago. Its really easy to use, and is quite good.

Gabriel McAdams
Yep! This is what I need. Not complex as FileHelper yet correct for even badly made csv's. Thanks for pointing it out Gabriel!
Dennis Decoene
+3  A: 

You can use ADO.NET to directly read the .CSV file into a DataTable. If you don't know how many fields will exist in advance, this can be a useful means of working with the data. This also has the advantage of not requiring any external libraries.

For details, please see Deborah Kurata's article on the subject.

Reed Copsey
A: 

StreamReader has been fast enough for me for pretty much every text file, though you are pretty screwed if you cant even guarantee value ordering.

StingyJack
that is why my program needs a function to define the mapping.
Dennis Decoene
OK... perhaps I am missing your meaning. Are you looking for a programmatic solution to importing CSV data into a database, or a tool that will let you define source (CSV) and destination values (DB) per file and import the data?
StingyJack