I am developing using C# 3 and .NET 3.5 and have an object where the contents of a CSV file (of an unknown format) are held in a byte[] property. I need to parse this byte[] and create a System.DataTable containing the columns and rows.
The problem is creating a System.DataTable where column data types match the data in the CSV.
I am currently using CsvReader to parse the byte[] CSV as this works well with streams and is very fast. Unfortunately this simply treats all data as strings.
I have tried using Jet/OLEDB to read from a CSV file and this successfully creates a DataTable with columns of different data types - however as this requires the use of a connection string I assume it can't be used to parse a byte[] in memory.
Is there a way this can be done, and if not what would be a reasonable way to deduce the data types and convert the untyped DataTable into a DataTable with specific column data types?