I have a csv file I am going to read from disk. I do not know up front how many columns or the names of the columns.
Any thoughts on how I should represent the fields. Ideally I want to say something like,
string Val = DataStructure.GetValue(i,ColumnName).
where i is the ith Row.
Oh just as an aside I will be parsing using the TextFieldParser class
http://msdn.microsoft.com/en-us/library/cakac7e6(v=vs.90).aspx
That sounds as if you would need a
DataTablewhich has aRowsandColumnsproperty.So you can say:
A
DataTableis a table of in-memory data. It can be used strongly typed (as suggested with theFieldmethod) but actually it stores it’s data as objects internally.You could use this parser to convert the csv to a DataTable.
Edit: I’ve only just seen that you want to use the
TextFieldParser. Here’s a possible simple approach to convert a csv to aDataTable: