avatar Bite 290. Class Rosters Data Conversion

You have been given a comma-delimited .csv file containing class roster data.

Your task is to re-format this data so it can be imported into your student information system. Only the output counts for this Bite.

Input

Each row of the input file contains data for a single student and all of their assigned classes, formatted as follows:

StudentID,StudentName,Class1,Class2,... (etc.)

Sample input row:

34215,"Smith, John",,MATH06-1 - PH,ENG06-1 - BlR,,,PE06-1 - TK

- StudentID: a 5-digit int

- StudentName: formatted as "Last, First", including quotation marks

- Classes: there may be any number of classes per student on a single row, each formatted as: CLASSNAME-SECTION - TeacherInitials

Notes:

-Each student appears only once in the input file.

-A student may be enrolled in zero or more classes. Students with no classes assigned should not be included as output.

-Not every class slot may be populated for a given student. Some examples of class listings are:

Class,Class,Class

,,Class,,,Class,,Class

,,,,,,,,,

Output

Your function should return a single list of individual class assignments, formatted as follows:

CLASSNAME-SECTION,SchoolYear,StudentID

Example return value:

['MATH06-1,2020,34215', 'ENG06-1,2020,34215', 'PE06-1,2020,34215']

Notes:

- The returned list should hold one entry per student per class assigned, in the same student order as the input file

- Class names should have teacher initials removed from the end. (You can assume there is always a " - " between the class name and the teacher name, excluding quotations.)

- The school year for output is always 2020

- No quotation marks should be included within in the output data.

Login and get coding
go back Intermediate level
Bitecoin 3X

50 out of 54 users completed this Bite.
Will you be Pythonista #51 to crack this Bite?
Resolution time: ~48 min. (avg. submissions of 5-240 min.)
Pythonistas rate this Bite 2.5 on a 1-10 difficulty scale.
» You can do it! 😌

Focus on this Bite hiding sidebars, turn on Focus Mode.

Ask for Help