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

Done #13

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

Done #13

wants to merge 18 commits into from

Conversation

backwizard
Copy link

@backwizard backwizard commented Oct 9, 2022

Repository : our repository link 🌷🌥
Visualize : visualize notebook ✨

Team

  • X
  • Fah
  • Alif

@annibuliful
Copy link
Collaborator

รบกวนใส่ link repo
ถ้ามี visualization ด้วยรบกวนใส่มาด้วยครับ

@pynsuphasueb
Copy link

pynsuphasueb commented Oct 9, 2022

Repository : our repository link 🌷🌥
Visualize : visualize notebook ✨

@annibuliful
Copy link
Collaborator

@backwizard @pynsuphasueb

เหมือนจะยังไม่มีไฟล์ JSON นะครับที่เป็นผลลัพธ์สุดท้าย
Screen Shot 2565-10-09 at 17 21 15

@backwizard
Copy link
Author

File dev_club.json ใน folder resources ปะครับหรือผมเข้าใจอะไรผิด

@annibuliful
Copy link
Collaborator

เจอแล้วครับ เดี๋ยวผมมาตรวจครับผม ขอโทษครับ พอดีไฟล์เยอะจัดเลยอ่านไม่ละเอียดเอง

Comment on lines +31 to +58
def read_xml_to_list_of_dict(path: str) -> tuple[List[dict], List[dict]]:
tree = ET.parse(path)
root = tree.getroot()
dev_mountain = []
dev_club = []
for child in root.iter('record'):
row = {}
for elem in child.iter():
if elem.tag == "record":
continue

if elem.tag == "BIRTHDAY" or elem.tag == "HIRED":
row[elem.tag] = datetime.strptime(elem.text, "%d-%m-%Y").strftime("%Y-%m-%d")
continue

row[elem.tag] = elem.text
if check_hired_greater_than_3year(row["HIRED"]) \
and row["POSITION"] in ["Airhostess", "Pilot", "Steward"] \
and row["STATUS"] == "1" \
and row["GENDER"] in ["0", "1"]:
dev_club.append(row)
continue

if row["STATUS"] not in ["1", "2", "3"] and row["GENDER"] not in ["0", "1"]:
continue

dev_mountain.append(row)
return dev_mountain, dev_club
Copy link
Collaborator

Choose a reason for hiding this comment

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

following Clean code book by Uncle Bob. you should create new variables to keep them be searchable

Suggested change
def read_xml_to_list_of_dict(path: str) -> tuple[List[dict], List[dict]]:
tree = ET.parse(path)
root = tree.getroot()
dev_mountain = []
dev_club = []
for child in root.iter('record'):
row = {}
for elem in child.iter():
if elem.tag == "record":
continue
if elem.tag == "BIRTHDAY" or elem.tag == "HIRED":
row[elem.tag] = datetime.strptime(elem.text, "%d-%m-%Y").strftime("%Y-%m-%d")
continue
row[elem.tag] = elem.text
if check_hired_greater_than_3year(row["HIRED"]) \
and row["POSITION"] in ["Airhostess", "Pilot", "Steward"] \
and row["STATUS"] == "1" \
and row["GENDER"] in ["0", "1"]:
dev_club.append(row)
continue
if row["STATUS"] not in ["1", "2", "3"] and row["GENDER"] not in ["0", "1"]:
continue
dev_mountain.append(row)
return dev_mountain, dev_club
def read_xml_to_list_of_dict(path: str) -> tuple[List[dict], List[dict]]:
STATUS = ["1", "2", "3"]
GENDER = ["0", "1"]
POSITION = ["Airhostess", "Pilot", "Steward"]
tree = ET.parse(path)
root = tree.getroot()
dev_mountain = []
dev_club = []
for child in root.iter('record'):
row = {}
for elem in child.iter():
if elem.tag == "record":
continue
if elem.tag == "BIRTHDAY" or elem.tag == "HIRED":
row[elem.tag] = datetime.strptime(elem.text, "%d-%m-%Y").strftime("%Y-%m-%d")
continue
row[elem.tag] = elem.text
if check_hired_greater_than_3year(row["HIRED"]) \
and row["POSITION"] in POSITION \
and row["STATUS"] == "1" \
and row["GENDER"] in GENDER:
dev_club.append(row)
continue
if row["STATUS"] not in STATUS and row["GENDER"] not in GENDER:
continue
dev_mountain.append(row)
return dev_mountain, dev_club


row[elem.tag] = elem.text

if row["STATUS"] not in ["1", "2", "3"] and row["GENDER"] not in ["0", "1"]:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above

@annibuliful
Copy link
Collaborator

@backwizard ขอ email หน่อยครับ

@backwizard
Copy link
Author

[email protected] ครับ

@annibuliful
Copy link
Collaborator

[email protected]

ทางเราจะส่ง pin password เพื่อสำหรับการยืนยันที่จะไปงานนะครับ เตรียมตัวอ่านเมล

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

Successfully merging this pull request may close these issues.

3 participants