-
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
Done #13
base: main
Are you sure you want to change the base?
Done #13
Conversation
รบกวนใส่ link repo |
Repository : our repository link 🌷🌥 |
File dev_club.json ใน folder resources ปะครับหรือผมเข้าใจอะไรผิด |
เจอแล้วครับ เดี๋ยวผมมาตรวจครับผม ขอโทษครับ พอดีไฟล์เยอะจัดเลยอ่านไม่ละเอียดเอง |
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 |
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.
following Clean code book by Uncle Bob. you should create new variables to keep them be searchable
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"]: |
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.
Same as above
@backwizard ขอ email หน่อยครับ |
[email protected] ครับ |
ทางเราจะส่ง pin password เพื่อสำหรับการยืนยันที่จะไปงานนะครับ เตรียมตัวอ่านเมล |
Repository : our repository link 🌷🌥
Visualize : visualize notebook ✨
Team