-
Notifications
You must be signed in to change notification settings - Fork 9
Mohamad Bader AA #6
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
base: main
Are you sure you want to change the base?
Changes from all commits
a43b8b3
f4cda42
fe100d6
d33ec92
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -156,3 +156,6 @@ dist | |
| vite.config.js.timestamp-* | ||
| vite.config.ts.timestamp-* | ||
|
|
||
| #pycache__/ | ||
| __pycache__/ | ||
| *.pyc | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| [ | ||
| { | ||
| "id": 1, | ||
| "name": "Alice Johnson", | ||
| "email": "alice.johnson@company.com", | ||
| "department": "Engineering", | ||
| "salary": 85000 | ||
| }, | ||
| { | ||
| "id": 2, | ||
| "name": "Bob Smith", | ||
| "email": "bob.smith@company.com", | ||
| "department": "Unknown", | ||
| "salary": 72000 | ||
| }, | ||
| { | ||
| "id": 3, | ||
| "name": "Carol Williams", | ||
| "email": "carol.williams@company.com", | ||
| "department": "Engineering", | ||
| "salary": null | ||
| }, | ||
| { | ||
| "id": 4, | ||
| "name": "David, Jr.", | ||
| "email": "david.brown@company.com", | ||
| "department": "Sales", | ||
| "salary": 68000 | ||
| }, | ||
| { | ||
| "id": 5, | ||
| "name": "Caf\u00e9 Owner", | ||
| "email": "eva@company.com", | ||
| "department": "Engineering", | ||
| "salary": 88000 | ||
| }, | ||
| { | ||
| "id": 6, | ||
| "name": "FRANK WILSON", | ||
| "email": "frank@company.com", | ||
| "department": "marketing", | ||
| "salary": 95000 | ||
| }, | ||
| { | ||
| "id": 7, | ||
| "name": "Grace Lee", | ||
| "email": "grace.lee@company.com", | ||
| "department": "Engineering", | ||
| "salary": null | ||
| }, | ||
| { | ||
| "id": 9, | ||
| "name": "Henry Davis", | ||
| "email": "henry.davis@company.com", | ||
| "department": "Sales", | ||
| "salary": 82000 | ||
| }, | ||
| { | ||
| "id": 11, | ||
| "name": "Linda Taylor", | ||
| "email": "linda.t@company.com", | ||
| "department": "HR", | ||
| "salary": 55000 | ||
| }, | ||
| { | ||
| "id": 12, | ||
| "name": "Mike Brown", | ||
| "email": "mike.b@company.com", | ||
| "department": "Sales", | ||
| "salary": null | ||
| }, | ||
| { | ||
| "id": 13, | ||
| "name": "Sarah Connor", | ||
| "email": "s.connor@sky.net", | ||
| "department": "Unknown", | ||
| "salary": null | ||
| }, | ||
| { | ||
| "id": 15, | ||
| "name": "John Doe", | ||
| "email": "john.doe@company.net", | ||
| "department": "Engineering", | ||
| "salary": 100000 | ||
| } | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,23 +13,29 @@ def clean_name(raw: str) -> str: | |
|
|
||
| Returns the cleaned string. An empty input returns "". | ||
| """ | ||
| raise NotImplementedError("Implement clean_name (Task 1)") | ||
| if not raw.strip(): | ||
| return "" | ||
| return raw.strip() | ||
|
|
||
|
|
||
| def clean_email(raw: str) -> str: | ||
| """Lowercase the email, strip surrounding whitespace. | ||
|
|
||
| Returns the cleaned string. An empty input returns "". | ||
| """ | ||
| raise NotImplementedError("Implement clean_email (Task 1)") | ||
| if not raw.strip(): | ||
| return "" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here |
||
| return raw.strip().lower() | ||
|
|
||
|
|
||
| def clean_department(raw: str) -> str: | ||
| """Return the department, or 'Unknown' if missing/empty. | ||
|
|
||
| Strip whitespace; treat empty string as missing. | ||
| """ | ||
| raise NotImplementedError("Implement clean_department (Task 1)") | ||
| if not raw.strip(): | ||
| return "Unknown" | ||
| return raw.strip() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: not wrong, but a more efficient version without calling |
||
|
|
||
|
|
||
| def clean_salary(raw: str) -> int | None: | ||
|
|
@@ -38,4 +44,12 @@ def clean_salary(raw: str) -> int | None: | |
| Handles inputs like "85000", " 95000", '"68,000"', "N/A", "". | ||
| Returns None when the value cannot be parsed (missing or "N/A"). | ||
| """ | ||
| raise NotImplementedError("Implement clean_salary (Task 1)") | ||
| if not raw.strip() or raw.strip().lower() == "n/a": | ||
| return None | ||
|
|
||
| # Ensure this line is aligned with the 'if' above it | ||
| cleaned = raw.strip().replace(",", "").replace('"', "") | ||
|
|
||
| # Ensure this block is aligned correctly | ||
| if cleaned.isdigit(): | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what happens here if you had a value like "85000 "? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| return int(cleaned) | ||
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.
raw.strip() already returns "" when the string is empty or only whitespace, so the explicit
if not raw.strip()check is redundant.return raw.strip()would have been enough :)