Skip to content

Instantly share code, notes, and snippets.

@shahzore-qureshi
Created April 1, 2013 04:17
Show Gist options
  • Select an option

  • Save shahzore-qureshi/5283223 to your computer and use it in GitHub Desktop.

Select an option

Save shahzore-qureshi/5283223 to your computer and use it in GitHub Desktop.
.NET File Parser
string filePath = "C:\\Users\\Administrator\\Documents\\Visual Studio 2012\\Projects\\MvcApplication1\\MvcApplication1\\Content\\Uploads\\zipcodes.txt";
System.IO.StreamReader file = new System.IO.StreamReader(filePath);
string line;
string[][] strings = new string[40][];
char[] delimiters = new char[3];
delimiters[0] = '\"';
delimiters[1] = ',';
delimiters[2] = '\n';
for (int i = 0; i < 40; i++)
{
line = file.ReadLine();
string[] tempArray = line.Split(delimiters);
List<String> tempList = new List<string>();
for (int j = 0; j < tempArray.Length; j++)
{
if (tempArray[j] != "")
{
tempList.Add(tempArray[j]);
}
}
strings[i] = tempList.ToArray();
}
file.Close();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment