Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You will be given four files as an input to your program. The description of each file is written below. Here is a compressed folder

You will be given four files as an input to your program. The description of each file is written below. Here is a compressed folder with a simple example input and the output . courses.csv This file contains the courses that a student is taking. Each course has a unique id , a name , and a teacher . students.csv This file contains all existing students in the database. Each student has a unique id , and a name . tests.csv This file contains all the tests for each course in the courses.csv file. The file has three columns: id: the tests unique id course_id: the course id that this test belongs to weight: how much of the students final grade the test is worth. For example, if a test is worth 50, that means that this test is worth 50% of the final grade for this course. The sum of all the weights of every test in a particular course should add up to 100. If thats not the case, your output should be an error message (see an example in the output section below). marks.csv This file contains all the marks each student has received for every test they have written. The file has three columns: test_id: the tests id student_id: the students id mark : The percentage grade the student received for the test (out of 100) Notes: Not every student is enrolled in all courses a student is considered to be enrolled in a course if they have taken a least one test for that course

Output Given the example input, here is the JSON file you need to generate:

Notice that: The data is contained within an object with a students key The students are ordered by id (the courses dont have to be ordered) The ids and grades are numbers Grades are rounded to two digits The totalAverage is the average of all the courses the student is enrolled in The students courseAverage in each course is determined by the mark they get in each test, and how much each test is worth) Not all data from the .csv files appears in the report.

Important: Make sure the output follows the format above (e.g, its an object with key students or error) and that it is valid JSON (you can use a validator ). Testing (Bonus) An important part of development is testing. As a bonus, you can add some unit tests to ensure your solution works for different cases. Usage Since your program will be used with different inputs, it must not hardcode the filenames or paths. Instead, take them as command line arguments. Arguments will be passed in the following order: {path-to-courses-file} {path-to-students-file} {path-to-tests-file} {path-to-marks-file} {path-to-output-file} For example: python main.py courses.csv students.csv tests.csv marks.csv output.json java Main courses.csv students.csv tests.csv marks.csv output.json node app.js courses.csv students.csv tests.csv marks.csv output.json If you attempt to hardcode the paths or get them from the standard input, your application will not pass our tests.

WE NEED TO GENERATE MAIN.PY FILE WHICH WILL TAKE 4 CSV FILE AS AN INPUT AND GIVES OUTPUT AS AN JSON FORMAT (output.json)As shown the image.

image text in transcribed

( reg: 12.03. B C D "students":[ 1 test Idstudent_id mark "id: 3. { "name":"Math". 2 1 1 78 "id": 1, "Yeacher. "Mrs. C" 3 3 2 "name":"A". "course Average: 74.2 4 3 1 95 "totalAverage: 72.03 5 4 1 32 "courses: 6 5 1 65 { } 7 5 1 78 B "id": 1, B C D 8 7 1 40 "name": "Biology, "id":3, "name", "C" 9 1 2 1 lid course_id weight 2 78 "teacher: "Mr. D", 10 2 2 87 "course Average': 90.1 2 1 1 10 11 3 2 15 } { 12 6 2 2 78 { 3 2 1 40 13 7 10 2 40 "id": 3, "name": "Biology". 4 3 1 50 14 1 3 78 "name":"Math", "Yeacher's "Mr. D", 15 2 82 "teacher': ''Mrs. C', "courseAverage: 90.1 5 4 4 2 40 16 3 3 95 "courseAverage": 74.2 }; 17 4 3 32 } 6 5 2 60 "id: 2 18 5 3 65 "name":"History 7 6 3 90 19 6 6 3 78 "id": 2, "teacher"Mrs. P! 20 7 3 40 "name": "History, 8 7 3 3 10 "course Average: 51.8 21 "teacher": "Mrs. p. . 9 22 "courseAverage": 51.8 { 23 } "d: 3, 10 24 1 "name":"Math": "Yeacher'" "Mrs. C", { "course Average": 74.2 "id": 2, "name": "B", "totalAverage: 62.15. B "courses: { "id": 1. id name "name": "Biology, teacher': 'Mr. D", "course Average": 50.1 2 1 A } { "id": 3. ": 3 2 B "name":"Math", "teacher": "Mrs. C", ''course Average: 74.2 4 3 C } } 5 1 "id": 3, "name": "C". "totalAverage": 72.03. "courses: B { "id": 1, teacher "name": "Biology" "teacher': ''Mr. D'. "course Average": 90.1 ? 1 Biology Mr. D OUTPUT.JSONI 3 2 History Mrs. P 1 3 Math Mrs. C { A 1 id Iname ( reg: 12.03. B C D "students":[ 1 test Idstudent_id mark "id: 3. { "name":"Math". 2 1 1 78 "id": 1, "Yeacher. "Mrs. C" 3 3 2 "name":"A". "course Average: 74.2 4 3 1 95 "totalAverage: 72.03 5 4 1 32 "courses: 6 5 1 65 { } 7 5 1 78 B "id": 1, B C D 8 7 1 40 "name": "Biology, "id":3, "name", "C" 9 1 2 1 lid course_id weight 2 78 "teacher: "Mr. D", 10 2 2 87 "course Average': 90.1 2 1 1 10 11 3 2 15 } { 12 6 2 2 78 { 3 2 1 40 13 7 10 2 40 "id": 3, "name": "Biology". 4 3 1 50 14 1 3 78 "name":"Math", "Yeacher's "Mr. D", 15 2 82 "teacher': ''Mrs. C', "courseAverage: 90.1 5 4 4 2 40 16 3 3 95 "courseAverage": 74.2 }; 17 4 3 32 } 6 5 2 60 "id: 2 18 5 3 65 "name":"History 7 6 3 90 19 6 6 3 78 "id": 2, "teacher"Mrs. P! 20 7 3 40 "name": "History, 8 7 3 3 10 "course Average: 51.8 21 "teacher": "Mrs. p. . 9 22 "courseAverage": 51.8 { 23 } "d: 3, 10 24 1 "name":"Math": "Yeacher'" "Mrs. C", { "course Average": 74.2 "id": 2, "name": "B", "totalAverage: 62.15. B "courses: { "id": 1. id name "name": "Biology, teacher': 'Mr. D", "course Average": 50.1 2 1 A } { "id": 3. ": 3 2 B "name":"Math", "teacher": "Mrs. C", ''course Average: 74.2 4 3 C } } 5 1 "id": 3, "name": "C". "totalAverage": 72.03. "courses: B { "id": 1, teacher "name": "Biology" "teacher': ''Mr. D'. "course Average": 90.1 ? 1 Biology Mr. D OUTPUT.JSONI 3 2 History Mrs. P 1 3 Math Mrs. C { A 1 id Iname

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database Foundations Technology Fundamentals For IT Success

Authors: Bob Bryla

1st Edition

0782143725, 9780782143720

More Books

Students also viewed these Databases questions

Question

1. Identify outcomes (e.g., quality, accidents).

Answered: 1 week ago