Skip to content

Instantly share code, notes, and snippets.

@StevenMcD
Created July 23, 2010 10:39
Show Gist options
  • Save StevenMcD/487273 to your computer and use it in GitHub Desktop.
Save StevenMcD/487273 to your computer and use it in GitHub Desktop.
public static List<string> GetColumnHeadings()
{
List<string> ColumnHeadings = new List<string>();
StreamReader rawFile = new StreamReader(@"filePath");
string stringFile = rawFile.ReadToEnd();
////
//// Split the rows into an array
////
string[] rows = stringFile.Split(new char[] { '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries);
//
// Split the tab separated fields (comma separated split commented)
//
//string[] dr = rows[i].Split(new char[] {','});
if (rows.Count() > 0)
{
string[] dr = rows[0].Split(new char[] {'\t'});
ColumnHeadings.AddRange(dr.Where(t => t != ""));
}
return ColumnHeadings;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment