Код ниже (с использованием фиктивного шифрования)
from multiprocessing import Pool
from contextlib import closing
import json
data = [{"emp_no": 10002,
"birth_date": "1964-06-02",
"first_name": "Bezalel",
"last_name": "Simmel",
"gender": "F",
"hire_date": "1985-11-21"}, {"emp_no": 100044,
"birth_date": "1964-06-02",
"first_name": "Bezalel",
"last_name": "Simmel",
"gender": "F",
"hire_date": "1985-11-21"}]
def ope_enc(x):
# Just add 1
x['emp_no'] = x['emp_no'] + 1
return x
if __name__ == '__main__':
with closing(Pool(processes=5)) as pool:
result = pool.map(ope_enc, data)
with open('res.json', 'w') as out:
json.dump(result, out)
res.json
[
{
"emp_no": 10003,
"birth_date": "1964-06-02",
"first_name": "Bezalel",
"last_name": "Simmel",
"gender": "F",
"hire_date": "1985-11-21"
},
{
"emp_no": 100045,
"birth_date": "1964-06-02",
"first_name": "Bezalel",
"last_name": "Simmel",
"gender": "F",
"hire_date": "1985-11-21"
}
]