Am new to C# and i want to know how to extract data from txt dataset and put it in c# dataset and perform some calculations with it.
This is how my dataset looks like
5.982 0.228 0.237 0.221 0.222 0.527
2.13 0.262 0.273 0.251 0.254 0.427
Here is my amateur code:
string file = "D://test1.txt";
string tableName = "table";
string delimiter = "\t";
DataSet ds = new DataSet();
StreamReader s = new StreamReader(file);
ds.Tables.Add(tableName);
string AllData = s.ReadToEnd();
foreach (string r in rows)
{
string[] items = r.Split(delimiter.ToCharArray());
ds.Tables[TableName].Rows.Add(items);
}
int MaxRows = ds.Tables[0].Rows.Count;
Console.Write(MaxRows);
Console.ReadLine();
It always shows an error:
Input array is longer than the number of columns in this table.