Fill This Form To Receive Instant Help
Homework answers / question archive / Assignment – 3(part-A) Python Given a file rules
Assignment – 3(part-A) Python
Given a file rules.json with rules written in the following format:
[ { "fields": { "profession": "Healthcare", "travel": "No", "symptomatic": "No" }, "results": "High Risk" }, { "fields": { "profession": "Healthcare", "travel": "No", "symptomatic": "Yes" }, "results": "High Risk" }, { "fields": { "profession": "Healthcare", "travel": "Yes", "symptomatic": "Yes" }, "results": "High Risk" }, { "fields": { "profession": "IT", "travel": "No", "symptomatic": "No" }, "results": "Low Risk" }, { "fields": { "profession": "IT", "travel": "Yes", "symptomatic": "No" }, "results": "Moderate Risk" }, { |
"fields": {
"profession": "IT",
"travel": "Yes",
"symptomatic": "Yes" },
"results": "High Risk"
},
{
"fields": {
"profession": "Police",
"travel": "No",
"symptomatic": "No"
},
"results": "Moderate Risk"
},
{
"fields": {
"profession": "Police",
"travel": "Yes",
"symptomatic": "No"
},
"results": "High Risk"
},
{
"fields": {
"profession": "Police",
"travel": "Yes",
"symptomatic": "Yes"
},
"results": "High Risk"
}
]
And a file data.csv that contains multiple records in the following format (Email, Profession, Travel, Symptomatic, Chronic):
|
Profession |
Travel |
Symptomatic |
Chronic |
a@b.com |
Healthcare |
No |
No |
No |
x@y.com |
IT |
Yes |
No |
No |
Based on the rules and the incoming data from data file, create a new file results.csv in the following schema:
|
Profession |
Travel |
Symptomatic |
Chronic |
Results |
a@b.com |
Healthcare |
No |
No |
No |
High Risk |
x@y.com |
IT |
Yes |
No |
No |
Moderate Risk |
Result is derived based on the values of the fields mentioned in the rules.
Instructions
data.csv has three columns (Profession, Travel, Symptomatic). Rules Tag is derived from these three keys from rules.json file. Once you get the tag, insert the Data record along with new Result column in results.csv file.
Grading Criteria:
(20)
If you use only If and else to derive logic – 12.5 marks
OR If you use Dictionary along with if and else – 25 marks
Else 0
<roll-number>.zip
------- lookup.py
------- rules.py (Code to derive Rules from JSON File)
------- results.csv (Code to lookup on the rules and insert into Result’s file) ------- flow_chart (png/jpeg/jpg)
Note:
It is recommended that the code is flexible to accommodate change in specs in the future assignments. This is however not a criterion for grading.