Advertisement
Guest User

Untitled

a guest
Jan 20th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.85 KB | None | 0 0
  1. import csv
  2.  
  3.  
  4. def build_csv(date):
  5. reader = csv.DictReader(date)
  6. inform = list(reader)
  7. return inform
  8.  
  9.  
  10. def get_info(date, x):
  11. g = {}
  12. for pos, i in enumerate(date):
  13. if i['Department'] == '':
  14. continue
  15. money = float(i['Employee Annual Salary'].split('$')[1])
  16. if i['Department'] in g:
  17. g[i['Department']].append((pos, money))
  18. else:
  19. g[i['Department']] = [(pos, money)]
  20. for i in g:
  21. print(i, g[i])
  22.  
  23.  
  24. if __name__ == '__main__':
  25. title = 'Employee_Salaries'#input('input name file')
  26. n = 20#int(input('input N'))
  27. data = None
  28. try:
  29. data = open('{}.csv'.format(title), encoding='UTF-8')
  30. except FileNotFoundError as e:
  31. print(e)
  32. if data is not None:
  33. result = build_csv(data)
  34. get_info(result, n)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement