Question: ll need to analyze the data contained within the file you just opened to ensure that it s in the correct format. Each data file
ll need to analyze the data contained within the file you just opened to ensure that it s in the correct format. Each data file contains a series of student responses in the following format: N12345678,B, A, D,D,C, B,D,A, C,C,D,B,A, B,A,C,B,D,A,C,A, A, B,D,D oF N12345678,B,,D,,C.B,JA,C,C,,B,A, B,A,,,,A, C,A, A, B,D, The first value is the student's ID number. The following 25 letters are the student responses to the exam. All values are separated by commas. If there is no letter following a comma, this means the student skipped answering the question Note that some lines of data may be corrupted! For example, this line of data does not have enough answers: N12345678,B,A,D,D, C, B And this line of data has too many answers: N12345678,B,A,D,D,C, B,D,A,C,C,D,8,A, B,A, C,B, D,A,C,A,A, B, D,D,A, B, C,D,E Your task for this part of the program is to do the following 1 Report the total number of lines of data stored in the file. 2. Analyze each line and make sure that it is "valid. o A valid line contains a comma-separated list of 26 values o The N number for a student is the first item on the line. It should begin with the character "N" and be followed by 8 numeric characters 3. If a line of data is not valid you should report it to the user by printing out an error message. You should also count the total number of valid lines of data in the file. 6 8 9 0 O. Here is a sample running of your program for the first two data files. A complete listing of the omputer Programmingputput for all data files can be found in the downloadable package for this assignment. Enter a class to grade (1.e. class1 for classi,txt): class1 Successfully opened class1.txt ANALYZING No errors found REPORT Total valid lines of data: . Total invalid lines of data: Enter a class to grade (i.e. classi for class1.txt): class2 Successfully opened class2.txt ANALYZING Invalid line of data: does not contain exactly 26 values: N00000023, ,A,D,D, ,B,D,A,c,c,,c,,B,A,C,B,D,A,C, A, A Invalid line of data: N# is invalid Neeee8e2,B,A.D.D.C,B,D,A,C,D,D,D,A,A,C,D,,A,C,A,A, B,D, D Invalid line of data: Na is invalid Invalid 1ine of data: does not contain exactly 26 values: REPORT Total valid lines of data: 21 Total invalid lines of data: 4 8 9
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
