Repository navigation
completed task-1, task-3 #5
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
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 |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| [ | ||
| { | ||
| "id": 1, | ||
| "name": "Alice Johnson", | ||
| "email": "[email protected]", | ||
| "department": "Engineering", | ||
| "salary": 85000 | ||
| }, | ||
| { | ||
| "id": 2, | ||
| "name": "Bob Smith", | ||
| "email": "[email protected]", | ||
| "department": "Unknown", | ||
| "salary": 72000 | ||
| }, | ||
| { | ||
| "id": 3, | ||
| "name": "Carol Williams", | ||
| "email": "[email protected]", | ||
| "department": "Engineering", | ||
| "salary": null | ||
| }, | ||
| { | ||
| "id": 4, | ||
| "name": "David, Jr.", | ||
| "email": "[email protected]", | ||
| "department": "Sales", | ||
| "salary": 68000 | ||
| }, | ||
| { | ||
| "id": 5, | ||
| "name": "Caf\u00e9 Owner", | ||
| "email": "[email protected]", | ||
| "department": "Engineering", | ||
| "salary": 88000 | ||
| }, | ||
| { | ||
| "id": 6, | ||
| "name": "FRANK WILSON", | ||
| "email": "[email protected]", | ||
| "department": "marketing", | ||
| "salary": 95000 | ||
| }, | ||
| { | ||
| "id": 7, | ||
| "name": "Grace Lee", | ||
| "email": "[email protected]", | ||
| "department": "Engineering", | ||
| "salary": null | ||
| }, | ||
| { | ||
| "id": 9, | ||
| "name": "Henry Davis", | ||
| "email": "[email protected]", | ||
| "department": "Sales", | ||
| "salary": 82000 | ||
| }, | ||
| { | ||
| "id": 11, | ||
| "name": "Linda Taylor", | ||
| "email": "[email protected]", | ||
| "department": "HR", | ||
| "salary": 55000 | ||
| }, | ||
| { | ||
| "id": 12, | ||
| "name": "Mike Brown", | ||
| "email": "[email protected]", | ||
| "department": "Sales", | ||
| "salary": null | ||
| }, | ||
| { | ||
| "id": 13, | ||
| "name": "Sarah Connor", | ||
| "email": "[email protected]", | ||
| "department": "Unknown", | ||
| "salary": -1 | ||
| }, | ||
| { | ||
| "id": 15, | ||
| "name": "John Doe", | ||
| "email": "[email protected]", | ||
| "department": "Engineering", | ||
| "salary": 100000 | ||
| } | ||
| ] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,29 +13,44 @@ def clean_name(raw: str) -> str: | |
|
|
||
| Returns the cleaned string. An empty input returns "". | ||
| """ | ||
| raise NotImplementedError("Implement clean_name (Task 1)") | ||
| 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)") | ||
| 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)") | ||
|
|
||
| normilized = 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 typo: normalized |
||
|
|
||
| if not normilized: | ||
| return "Unknown" | ||
|
|
||
| return normilized | ||
|
|
||
| def clean_salary(raw: str) -> int | None: | ||
| """Parse a messy salary cell into an int. | ||
|
|
||
| Handles inputs like "85000", " 95000", '"68,000"', "N/A", "". | ||
| Returns None when the value cannot be parsed (missing or "N/A"). | ||
|
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. not: handle negative values |
||
| """ | ||
| raise NotImplementedError("Implement clean_salary (Task 1)") | ||
| normilized = raw.strip() | ||
|
|
||
| if not normilized or normilized == "N/A": | ||
| return None | ||
|
|
||
| normilized = normilized.replace('"', "") | ||
| normilized = normilized.replace(",", "") | ||
|
|
||
| try: | ||
| return int(normilized) | ||
| except ValueError: | ||
|
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. I would log the error type for easier debug! |
||
| return None | ||
|
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. wrong file type! it should be |
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.
nit: case normalization is something that we usually do - even though it was not mentioned in the instructions!