You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
990 B

5 years ago
  1. #!/usr/bin/env python3
  2. #title :11-2.py
  3. #description :11.2: JSON-stationslijsten lezen
  4. #author :Marcel Haazen
  5. #email :marcel@haazen.xyz
  6. #date :07-11-2019 - 13:45
  7. #edit_date :07-11-2019 - 14:05
  8. #version :0.1
  9. #usage :python3 11-2.py
  10. #notes :
  11. #python_version :3.7.4
  12. #==============================================================================
  13. import json
  14. with open("stationslijst.json", "r") as json_file:
  15. data = json.load(json_file)
  16. lng = []
  17. print("Dit zijn de namen, codes en types van de stations:")
  18. for station in data["payload"]:
  19. name = station["namen"]["lang"]
  20. code = station["code"]
  21. st = station["stationType"]
  22. lng.append(station['lng'])
  23. print("{:25} - {:5} : {:5}".format(name, code, st))
  24. for station in data["payload"]:
  25. if station["lng"] == max(lng):
  26. print("\nHet meest oostelijke gelegen station is:", station["namen"]["lang"])