Skip to content
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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

puthita-sam
Copy link

@puthita-sam puthita-sam commented Oct 9, 2022

@annibuliful
Copy link
Collaborator

annibuliful commented Oct 9, 2022

รบกวนใส่ชื่อทีมและกด repo link ด้วยครับ
ถ้ามี visualization ด้วยให้ screentshot มาด้วย
@puthita-sam

@lordbenz
Copy link
Contributor

lordbenz commented Oct 9, 2022

อันนี้ Repo Link https://github.com/puthita-sam/hackathon-season2/tree/feature/init-visualizer @annibuliful
ส่วน โบนัส Visualization รบกวน @puthita-sam เพิ่ม screen shot หน่อยนะครับจะได้เช็คง่ายๆ

@puthita-sam
Copy link
Author

image

screenshot  ค่ะ ทีม 3 คน: puthita-sam, VarutA, NTPSB

from datetime import datetime

import os
import xmltodict
Copy link
Collaborator

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

Comment on lines +80 to +103
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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Comment on lines +97 to +100
if emp_id not in temp_dict:
temp_dict[emp_id] = {}
temp_dict[emp_id][passport_no] = 'checked'
pristine_records.append(record)
Copy link
Collaborator

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants