Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv # use the csv module
- import collections
- f = open('dmssalaries.csv') # ref open file as f: http://dmssalaries.herokuapp.com/salaries?employee_name=&employee_type=&agency_name=&class_code=&salaries_length=10
- # pass f to csv module to csv.reader to parse rows of file
- csv_f = csv.reader(f)
- db = [x for x in csv_f]
- #print len(r[0])
- csv_header = db[0]
- agency_name, budget_entity,\
- pos_num, last_n, first_n, middle_n, \
- employee_type, full_part, class_code, \
- class_title, h_date, salary, hourly_salary = [ csv_header.index(i) for i in csv_header ]
- def get_all_depts():
- depts = set()
- for item in range(len(db)):
- depts.add(db[item][agency_name])
- return list(depts)
- def search_by_name(first, middle, last):
- matches = []
- for index in range(len(db)):
- name = db[index]
- if first.lower() in name[first_n].lower():
- matches.append( ( '{}'.format(name[first_n]), index) )
- elif middle.lower() in name[middle_n].lower():
- matches.append( ('{}'.format(name[middle_n]), index) )
- elif last.lower() in name[last_n].lower():
- matches.append( ('{}'.format(name[last_n]), index) )
- return matches
- def taxes_pay():
- for department in get_all_depts():
- print 'Your Florida tax money currently pays: ' + department
- target_ids = [ value for key,value in search_by_name('Marco', 'Marco', 'Marco') ] # generate array of ids for name matches
- # salary = db[target_ids[num]][salary]
- # name = db[target_ids[num]][first_n] + db[target_ids[num]][last_n]
- # career = db[target_ids[num]][class_title]
- for num in range(len(target_ids)):
- print db[target_ids[num]][first_n], db[target_ids[num]][last_n], "makes", \
- db[target_ids[num]][salary],"annually working as a", \
- db[target_ids[num]][class_title]
- num += 1
- print 'Length of all total entries for passed names: ', len(target_ids)
- taxes_pay()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement