I have a list of arrays written to a text file. Each array holds 7 items: The first item is the class date, and the following six items are the student IDs who where given a task on that date. I want to be able to scan through the list of arrays and write to a separate file the dates each student is chosen.
For example, if student 04 is selected multiple times the file will show on the fourth line the dates that student was given a task. I am trying to use a for each loop to scan through each line.
Example data of the list of arrays stored:
00/00/0000,02,04,05,06,07,08 11/11/1111,01,02,05,06,08,09 22/22/2222,02,03,05,06,07,08
What i want to achieve is studentId,taskDate (Multiple if student has done multiple tasks), like this:
01,11/11/1111 02,00/00/0000,11/11/1111,22/22/2222 03,22/22/2222 04,00/00/0000 05,00/00/0000,11/11/1111,22/22/2222 06,00/00/0000,11/11/1111,22/22/2222 07,00/00/0000,22/22/2222 08,00/00/0000,11/11/1111,22/22/2222
So far I read from the text file as follows
string readrecord = @"C:\classes\tasks\taskrecord.txt";
List<string> lines = File.ReadAllLines(readrecord).ToList();
foreach (var line in lines)
{
string[] tasks= entries[1].Split(',');
taskDate = tasks[0];
stu1 = tasks[1];
stu2 = tasks[2];
stu3 = tasks[3];
stu4 = tasks[4];
stu5 = tasks[5];
stu6 = tasks[6];
}
Now I am trying to scan the list and write taskDate to file if stu1 to stu6 is equal to specific student id:
string writeTaskDate = @"C:\classes\tasks\dateRecord.txt";
if(stu1 == 01||stu2 == 01||stu3 == 01||stu4 == 01||stu5 == 01||stu6 == 01)
{
//--How do i add taskDate to end of Line 1 of "writeTaskDate"??
}
else If(stu1 == 02||stu2 == 02||stu3 == 02||stu4 == 02||stu5 == 02||stu6 == 02
{
//--How do i add taskDate to end of Line 2 of "writeTaskDate"??
}
...and so on for each student i have an ID for. Any advice is appreciated.