Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- def build_csv(date):
- reader = csv.DictReader(date)
- inform = list(reader)
- return inform
- def get_info(date, x):
- g = {}
- for pos, i in enumerate(date):
- if i['Department'] == '':
- continue
- money = float(i['Employee Annual Salary'].split('$')[1])
- if i['Department'] in g:
- g[i['Department']].append((pos, money))
- else:
- g[i['Department']] = [(pos, money)]
- for i in g:
- print(i, g[i])
- if __name__ == '__main__':
- title = 'Employee_Salaries'#input('input name file')
- n = 20#int(input('input N'))
- data = None
- try:
- data = open('{}.csv'.format(title), encoding='UTF-8')
- except FileNotFoundError as e:
- print(e)
- if data is not None:
- result = build_csv(data)
- get_info(result, n)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement