Advertisement
Treque

Footy

Oct 15th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import csv
  2. f = open("C:/Users/scarr/Downloads/football.csv", "r")
  3. goal_data = f.read()
  4. goal_data = goal_data.split("\n")
  5. goal_differences = []
  6. team_names = []
  7. for i in goal_data[1:]:
  8. row = i.split(",")
  9. goals_scored = int(row[5])
  10. goals_conceded = int(row[6])
  11. goal_differential = goals_scored - goals_conceded
  12. goal_differences.append(goal_differential)
  13. for i in goal_data[1:]:
  14. x = i.split(",")
  15. team = x[0]
  16. team_names.append(team)
  17. abs_differences = [abs(x) for x in goal_differences]
  18. team_dictionary = dict(zip(team_names, abs_differences))
  19. print(team_dictionary)
  20. print(min(team_dictionary.items(), key=lambda x: x[1]))
  21. print(max(team_dictionary.items(), key=lambda x: x[1]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement