My list has the following dictionaries.
[OrderedDict([('Employee Number', '1'), ('Employee Name', 'Ms. A'), ('RMG SPOC', 'X'), ('Total Experience (yrs)', '3.06'), ('Days Unallocated', '18'), ('Skill Details', 'Manual testing'), ('Contact Number', '1234')]), OrderedDict([('Employee Number', '2'), ('Employee Name', 'Mr. B'), ('RMG SPOC', 'Y'), ('Total Experience (yrs)', '2.51'), ('Days Unallocated', '28'), ('Skill Details', 'Manual Testing'), ('Contact Number', '2345')]), OrderedDict([('Employee Number', '3'), ('Employee Name', 'Mr. C'), ('RMG SPOC', 'Z'), ('Total Experience (yrs)', '1.86'), ('Days Unallocated', '9'), ('Skill Details', 'C++, Manual Testing, Oracle'), ('Contact Number', '4567')]), OrderedDict([('Employee Number', '4'), ('Employee Name', 'Mr. D'), ('RMG SPOC', 'xyz'), ('Total Experience (yrs)', '7.68'), ('Days Unallocated', '23'), ('Skill Details', 'Manual Testing, SQL, HCM'), ('Contact Number', '789')])]
I am pushing these values to database by preparing a dictionary using for loop on the above data.
emp_data = {"employee_name" : data['Employee Name'],
"employee_number" : data['Employee Number'],
"date_added" : datetime.datetime.now(),
"rmg_spoc" : data['RMG SPOC'],
"status" : "To be evaluated",
"total_experience" : data['Total Experience (yrs)'],
"days_unallocated" : data['Days Unallocated'],
"skill_details" : data['Skill Details'],
"contact_number" : data['Contact Number'],
"reviewer" : "To be assigned",
"comments" : "To be added"}
I get the original data from a excel/csv. This is working fine as long as the keys match the data in the provided excel/csv.
In case, the excel/csv has 'Employee Name' as 'employee name' or 'EMPLOYEE NAME', then the above way will not work.
Is there a way in which I can handle this, such that keys like "employee name" is mapped to value matching any of the format('Employee Name', 'EMPLOYEE NAME', 'employee name'), "rmg_spoc" matching any of the format('RMG', 'rmg', 'RMG SPOC', 'rmg spoc', 'rmg*'), "total_experience" matching any of the format('Total Experience', 'total experience', '* [E][e]xperience *').