Untitled

mail@pastecode.io avatar
unknown
python
8 months ago
797 B
5
Indexable
Never
import json

file_path = 'data.json'

with open(file_path, 'r') as f:
    all_employee = json.load(f)['employees']


def getSalaries(employee_list):
    return [(employee['name'], employee['salary']) for employee in employee_list]


def filterEmployee(conditions):
    filtered_list = all_employee
    for condition in conditions:
        filtered_list = [employee for employee in filtered_list if
                         employee.get(condition[0]) == condition[1]]
    return filtered_list


allSalaries = getSalaries(all_employee)

activeEmployee = filterEmployee([('status', 'True')]) ##biblioteka do ladniejszych warunkow by sie zdala
activeEmployeeSalaries = getSalaries(activeEmployee)

print(f"all emp salaries: {allSalaries}\n"
      f"active employee salaries {activeEmployeeSalaries}")
Leave a Comment