public static System.Data.DataTable ReadTabDelimeted(string path)
{
StreamReader sr = new StreamReader(path);
System.Data.DataTable dt = new System.Data.DataTable();
{
StreamReader sr = new StreamReader(path);
System.Data.DataTable dt = new System.Data.DataTable();
try
{
if (sr.Peek() > 0)
{
string[] headers = sr.ReadLine().Split('\t');
{
if (sr.Peek() > 0)
{
string[] headers = sr.ReadLine().Split('\t');
foreach (string header in headers)
dt.Columns.Add(header);
}
dt.Columns.Add(header);
}
while (sr.Peek() > 0)
{
string[] cells = sr.ReadLine().Split('\t');
{
string[] cells = sr.ReadLine().Split('\t');
DataRow dr = dt.NewRow();
for (int i = 0; i < cells.Length; i++)
{
dr[i] = cells[i];
}
{
dr[i] = cells[i];
}
dt.Rows.Add(dr);
}
}
finally
{
sr.Close();
}
return dt;
}
}
}
finally
{
sr.Close();
}
return dt;
}
No comments:
Post a Comment