Answered step by step
Verified Expert Solution
Question
1 Approved Answer
You will write a program which will perform a filtering action. In your program you will get the name of the JSON file as an
You will write a program which will perform a filtering action. In your program you will get the name of the JSON file as an input from the user. If file exist, proceed to prompt more options, otherwise let user know file was not found, let user re enter, until user presses Q q is exit If file exist, prompt the user with the filtering options. User can also choose to save new filtered data in separate file.
Prompt user to give you name of the JSON file. JSON object will have these keys id firstname, lastname, age, city, phonenumber
You can always assume, JSON file will have data and it will be in the same format shown above.
For testing purposes use the following file: data.JSONDownload data.JSON
If file was found, proceed to show these filtering options.
filter by age
a user must enter min and max age, show all rows that have age between min and max including the min and max number.
b if user entered the same number for min and max, that means user is looking specifically for that age
c you must do checking where min shouldn't be greater than max. And min cannot be less than
filter by city
a once user enters city, present with all data that matches the city name, if none exist, just show a message saying no data found.
filter by last name
a once user enters last name, present with all data that matches the last name, if none exist, just show a message saying no data found.
filter by first name
a once user enters first name, present with all data that matches the first name, if none exist, just show a message saying no data found.
filter by id
a same rules like age but with id instead.
Q to quit.
If data was filtered, give user an option to save filtered data.
User.py Requirements
Must include all variables and all variables must be private id firstname, lastname, age, city, phonenumber
Must include constructor accepting all variables above.
Must include getters and setter for all variables.
Must have an overriden str function to print User info in the same format required by the assignment. example output below
Must have a function called inrangemin max
inrange will take min and max numbers then return true if age is within the limit or return false if it is not.
Sample output:
Please enter JSON file name or Q to exit: test
File was not found.
Please enter JSON file name or Q to exit: data.JSON
File found.
Here are your filtering options:
Filter by age min and max
Filter by city
Filter by last name
Filter by first name
Filter by id min and max
or enter Q to quit
Please give min age for filtering:
Please give max age for filtering:
Max cannot be less than min!
Please give max age for filtering:
Here is the filtered data based on age between and inclusively.
User ID:
Alex Anderson
Omaha, NE
User ID:
Seth Green
Denver, CO
If no data was found, print a message saying no data was found, then move on to asking about going back to the main menu
Would you like to save the filtered data? YN
Y
What should the name of the new file be
filteredage
Your filtered data was saved in filteredage.JSON this must output a file with filtered data above saved in the same format as the original data.
Would you like to go back to the main menu? YN
N
Terminating program. Good bye!
There is a lot of repetitive functionality in this assignment, I am expecting you to be very efficient with your solutions. Utilize for loop, while loop and functions to reuse your code.
Your submission MUST include these file:
User.py Must satisfy all requirements mentioned above.
main.py must have main function in it Failure to include main function in your submission will result in
You can include more classes or functions if you would like, but these are minimum requirements.
Main function Ex:
def main:
# your logic here
if namemain:
main
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started