-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/init visualizer #17
base: main
Are you sure you want to change the base?
Feature/init visualizer #17
Conversation
รบกวนใส่ชื่อทีมและกด repo link ด้วยครับ |
อันนี้ Repo Link https://github.com/puthita-sam/hackathon-season2/tree/feature/init-visualizer @annibuliful |
from datetime import datetime | ||
|
||
import os | ||
import xmltodict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is non standard library to that's not allowed to use
def clean_data(data_dict): | ||
temp_dict = {} | ||
pristine_records = [] | ||
|
||
for index in range(len(data_dict['records']['record'])): | ||
record = data_dict['records']['record'][index] | ||
emp_id = record['EMPID'] | ||
passport_no = record['PASSPORT'] | ||
if emp_id in temp_dict and passport_no in temp_dict[emp_id]: | ||
print('found duplicate on employee id: {} and passport no: {} > ignore'.format(emp_id, passport_no)) | ||
elif 'GENDER' in record and record['GENDER'] not in ['0', '1']: | ||
print('wrong gender type ({}) > ignore'.format(record['GENDER'])) | ||
elif 'STATUS' in record and record['STATUS'] not in ['1', '2', '3']: | ||
print('wrong status type ({}) > ignore'.format(record['STATUS'])) | ||
elif 'STATUS' in record and record['STATUS'] != '1': | ||
print('employee status not active ({}) > ignore'.format(record['STATUS'])) | ||
else: | ||
if emp_id not in temp_dict: | ||
temp_dict[emp_id] = {} | ||
temp_dict[emp_id][passport_no] = 'checked' | ||
pristine_records.append(record) | ||
|
||
data_dict['records']['record'] = pristine_records | ||
return data_dict |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def clean_data(data_dict): | |
temp_dict = {} | |
pristine_records = [] | |
for index in range(len(data_dict['records']['record'])): | |
record = data_dict['records']['record'][index] | |
emp_id = record['EMPID'] | |
passport_no = record['PASSPORT'] | |
if emp_id in temp_dict and passport_no in temp_dict[emp_id]: | |
print('found duplicate on employee id: {} and passport no: {} > ignore'.format(emp_id, passport_no)) | |
elif 'GENDER' in record and record['GENDER'] not in ['0', '1']: | |
print('wrong gender type ({}) > ignore'.format(record['GENDER'])) | |
elif 'STATUS' in record and record['STATUS'] not in ['1', '2', '3']: | |
print('wrong status type ({}) > ignore'.format(record['STATUS'])) | |
elif 'STATUS' in record and record['STATUS'] != '1': | |
print('employee status not active ({}) > ignore'.format(record['STATUS'])) | |
else: | |
if emp_id not in temp_dict: | |
temp_dict[emp_id] = {} | |
temp_dict[emp_id][passport_no] = 'checked' | |
pristine_records.append(record) | |
data_dict['records']['record'] = pristine_records | |
return data_dict | |
def clean_data(data_dict): | |
STATUS = ['1', '2', '3'] | |
GENDER = ['0','1'] | |
temp_dict = {} | |
pristine_records = [] | |
for index in range(len(data_dict['records']['record'])): | |
record = data_dict['records']['record'][index] | |
emp_id = record['EMPID'] | |
passport_no = record['PASSPORT'] | |
if emp_id in temp_dict and passport_no in temp_dict[emp_id]: | |
print('found duplicate on employee id: {} and passport no: {} > ignore'.format(emp_id, passport_no)) | |
elif 'GENDER' in record and record['GENDER'] not in GENDER: | |
print('wrong gender type ({}) > ignore'.format(record['GENDER'])) | |
elif 'STATUS' in record and record['STATUS'] not in STATUS: | |
print('wrong status type ({}) > ignore'.format(record['STATUS'])) | |
elif 'STATUS' in record and record['STATUS'] != '1': | |
print('employee status not active ({}) > ignore'.format(record['STATUS'])) | |
else: | |
if emp_id not in temp_dict: | |
temp_dict[emp_id] = {} | |
temp_dict[emp_id][passport_no] = 'checked' | |
pristine_records.append(record) | |
data_dict['records']['record'] = pristine_records | |
return data_dict |
if emp_id not in temp_dict: | ||
temp_dict[emp_id] = {} | ||
temp_dict[emp_id][passport_no] = 'checked' | ||
pristine_records.append(record) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it's used to prevent duplicated record right?
Repo Link https://github.com/puthita-sam/hackathon-season2/tree/feature/init-visualizer