import csv
#Reading File contents from given Location
def read_emplyees(csv_file_location):
    csv.register_dialect('empDialect',skipinitialspace =True,strict =True)
    employee_file = csv.DictReader(open(csv_file_location),dialect='empDialect')
    employee_list = []
    for data in employee_file:
        employee_list.append(data)
    return employee_list
employee_list = read_employess('/home/<username>/data/employees.csv')   
print(employee_list)
#Processing Data from employee list created in read function
def process_data(employee_list):
    department_list = []
    for employee_data in employee_list:
        department_list.append(employee_data['Department'])
    department_data = {}
  for department_name in set(department_list):
    department_data[department_name] = department_list.count(department_name)
  return department_data
dictionary = process_data(employee_list)
print(dictionary)
#Creating new file to copy reports 
def write_report(dictionary, report_file):
     with open(report_file, "w+") as f:
    for k in sorted(dictionary):
      f.write(str(k)+':'+str(dictionary[k])+'\n')
    f.close()
write_report(dictionary, '/home/<username>/data/report.txt')    

dfd86535345a30dcd3f432f28cbcc8e84a0788fa
import csv
#Reading File contents from given Location
def read_emplyees(csv_file_location):
    csv.register_dialect('empDialect',skipinitialspace =True,strict =True)
    employee_file = csv.DictReader(open(csv_file_location),dialect='empDialect')
    employee_list = []
    for data in employee_file:
        employee_list.append(data)
    return employee_list
employee_list = read_employess('/home/<username>/data/employees.csv')   
print(employee_list)
#Processing Data from employee list created in read function
def process_data(employee_list):
    department_list = []
    for employee_data in employee_list:
        department_list.append(employee_data['Department'])
    department_data = {}
  for department_name in set(department_list):
    department_data[department_name] = department_list.count(department_name)
  return department_data
dictionary = process_data(employee_list)
print(dictionary)
#Creating new file to copy reports 
def write_report(dictionary, report_file):
     with open(report_file, "w+") as f:
    for k in sorted(dictionary):
      f.write(str(k)+':'+str(dictionary[k])+'\n')
    f.close()
write_report(dictionary, '/home/<username>/data/report.txt')    
