I am currently trying to parse a .txt file containing information listed like this: name/ID number/email/GPA. Here are a few lines showing what the text file looks like.
(LIST (LIST 'Doe 'Jane 'F ) '8888675309 'jfdoe@mail.university.edu 2.3073320999676614 )
(LIST (LIST 'Doe 'John 'F ) 'NONE 'johnfdoe@mail.university.edu 3.1915725161177115 )
(LIST (LIST 'Doe 'Jim 'F ) '8885551234 'jimdoe@mail.university.edu 3.448215586562192 )
In my current code all I am doing is printing the text file line by line to a console window.
static void Main(string[] args)
{
StreamReader inFile;
string inLine;
if (File.Exists("Students.txt"))
{
try
{
inFile = new StreamReader("Students.txt");
while ((inLine = inFile.ReadLine()) != null)
{
Console.WriteLine(inLine);
}
}
catch (System.IO.IOException exc)
{
Console.WriteLine("Error");
}
Console.ReadLine();
}
}
I need to able to, for example, find all the students that have a GPA above 3.0 and print their name and GPA to another text file. I understand how to print to another file, however, I am unsure how to access the individual columns, such as the GPA, since this file does not seem to have any common delimiters that would make using a Split() practical. Any help or insight on how to accomplish this would be appreciated.