Ejemplo n.º 1
0
 def __init__(self, yearInt, cleanFileStr):
     self.dataYear = yearInt
     self.cleanFileName = cleanFileStr
     self.employeeMasterList = open_cleanfile(self.cleanFileName)  #  list of e_list
     self.uniquePositions = count_positions(self.employeeMasterList, "d")  # uniquePositions is sorted from highest f; list of tuples
     #simple stats per year
     self.uniquePositionsCount = len(self.uniquePositions)
     self.totalSalary = sumSalary(self.employeeMasterList)
Ejemplo n.º 2
0

def count_positions(employee_list, order):
    e_pos_dict = {} # dictionary of the employee positions
    sorted_e_pos_list = None
    try:
        for e in employee_list:
            if (e[1] in e_pos_dict):
                e_pos_dict[e[1]] += 1
            else:
                e_pos_dict[e[1]] = 1
        # See if user wants the list sorted by ascending or descending order
        user_choice = order[0].upper()
        if (user_choice == "A"):
            sorted_e_pos_list = sorted(e_pos_dict.items(), key=operator.itemgetter(1), reverse=False)
        elif (user_choice == "D"):
            sorted_e_pos_list = sorted(e_pos_dict.items(), key=operator.itemgetter(1), reverse=True)
        else:
            print "Please enter either 'A' or 'D' as the second argument in count_positions to get the positions sorted "
    finally:
        return sorted_e_pos_list
        # pprint.pprint(sorted_e_pos_list)
        # return e_pos_dict

##### TESTING ######
clean_employee_list = open_cleanfile("uvmSalary15.csv")
sorted_position_list = count_positions(clean_employee_list, "a")
# see how many unique positions there are
# print type(sorted_position_list)
#print "This is how many unique positions of employment there are at UVM: ", len(sorted_position_list)