Open
Conversation
Collaborator
|
รบกวนใส่ link repo |
|
Repository : our repository link 🌷🌥 |
Collaborator
Author
|
File dev_club.json ใน folder resources ปะครับหรือผมเข้าใจอะไรผิด |
Collaborator
|
เจอแล้วครับ เดี๋ยวผมมาตรวจครับผม ขอโทษครับ พอดีไฟล์เยอะจัดเลยอ่านไม่ละเอียดเอง |
annibuliful
requested changes
Oct 10, 2022
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 |
Collaborator
There was a problem hiding this comment.
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"]: |
Collaborator
|
@backwizard ขอ email หน่อยครับ |
Author
|
kongphopse@gmail.com ครับ |
Collaborator
|
ทางเราจะส่ง pin password เพื่อสำหรับการยืนยันที่จะไปงานนะครับ เตรียมตัวอ่านเมล |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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