FileHelpers icon indicating copy to clipboard operation
FileHelpers copied to clipboard

Question about reading CSV file to DataTable with unknown columns

Open AFract opened this issue 5 years ago • 0 comments

Hello,

I would like to be able to read a CSV to a DataTable. I do not know in advance the count and the name of the columns, so I would like to be able to automatically generate a DataTable structure with column names based on file header. The content to load is a Stream, not a physical file.

I have tried to figure how to do this with FileHelpers (last version) with various methods (CommonEngine.CsvToDataTable(), CsvEngine.CsvToDataTable(), FileHelperEngine.ReadStreamAsDT etc) but nothing worked (because these methods seems to be intended to work from physical files, or the structure needs to be known in advance, etc). Last month I created a StackOverflow question to explain what kind of problems I encountered but I didn't received any answer : https://stackoverflow.com/questions/56361716/using-filehelpers-to-read-a-dynamic-csv-to-datatable

Could you please help me ?

Usually I use your library to load files to objects, as the structure is known in advance, and I really like it. So if it's possible to achieve something like this what I described previously with it, I'd be glad to use it.

Thank you very much.

AFract avatar Jun 10 '19 11:06 AFract