Question: Python question: I have a file with several lines similar to this: Line1. {id: 121, timestamp: 2020-11-16T11:55:55.000 , station_name: Blackstone Ave & Hyde

Python question:

I have a file with several lines similar to this:

Line1.

{"id": "121", "timestamp": "2020-11-16T11:55:55.000", "station_name": "Blackstone Ave & Hyde Park Blvd", "total_docks": "19", "docks_in_service": "19", "available_docks": "13", "available_bikes": "6", "percent_full": "32", "status": "In Service", "latitude": "41.802562", "longitude": "-87.590368", "location": {"type": "Point", "coordinates": [-87.590368, 41.802562]}, "record": "12120201116115555"},

Line500

{"id": "135", "timestamp": "2020-11-16T11:55:55.000", "station_name": "Halsted St & 21st St", "total_docks": "11", "docks_in_service": "11", "available_docks": "7", "available_bikes": "4", "percent_full": "36", "status": "In Service", "latitude": "41.85378", "longitude": "-87.64665", "location": {"type": "Point", "coordinates": [-87.64665, 41.85378]}, "record": "13520201116115555"},

Etc.

The file name is called example.txt.

I need help with the following:

  1. Create a class that hold the the data in bold for each line.
  2. Create a constructor to set data values
  3. Use the @property decorator to make at least one property of the class private.
  4. Use the @???.setter method to validate the private property in some way (ex: check if its numeric, change it's data type, change it's length) before setting its value
  5. Create one or more regular class methods to CALCULATE other relevant values from the data attributes stored as a part of the class (The class could store latitude & longitude OR timestamp).
  6. Override the __str__ method to print a string representation of a BikeStation that looks like the String below

Halsted St & 21st St had 4 bikes on Mon Nov 16 11:55:55 2020

Blackstone Ave & Hyde Park Blvd had 6 bikes on Mon Nov 16 11:55:55 2020

Stations: [135, 121] Bikes Available 17 Docks Available 20

NB: the program needs to prompt the user to input the file

Please let me know if you need more details. Thanks

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!