We are receiving a CSV file as Stream. Now we are creating the data table from the stream as below
while (!reader.EndOfStream)
{
try
{
string[] rows = reader.ReadLine().Split(',');
DataRow dr = dt.NewRow();
for (int i = 0; i < dt.Columns.Count; i++)
{
dr[i] = rows[i].Replace("\"", "");
}
dt.Rows.Add(dr);
}
catch (Exception ex)
{
continue;
}
}
It's taking some time to create the Data Table as CSV in Stream contains lot of records. We want to have the best solution to do the same. Can you please share, If you know any other better solution than this.