diff --git a/task-1/output/clean_users.json b/task-1/output/clean_users.json new file mode 100644 index 0000000..38a6b87 --- /dev/null +++ b/task-1/output/clean_users.json @@ -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": -1 + }, + { + "id": 15, + "name": "John Doe", + "email": "john.doe@company.net", + "department": "Engineering", + "salary": 100000 + } +] \ No newline at end of file diff --git a/task-1/src/utils.py b/task-1/src/utils.py index 2762398..b69cf55 100644 --- a/task-1/src/utils.py +++ b/task-1/src/utils.py @@ -9,27 +9,17 @@ def clean_name(raw: str) -> str: - """Strip leading/trailing whitespace from a name. - - Returns the cleaned string. An empty input returns "". - """ - raise NotImplementedError("Implement clean_name (Task 1)") + return raw.strip().title() 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)") + cleaned = raw.strip() + return cleaned.title() if cleaned else "Unknown" def clean_salary(raw: str) -> int | None: @@ -38,4 +28,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)") + cleaned = raw.strip().replace(",", "").replace('"', "") + if not cleaned or cleaned.upper() == "N/A": + return None + + try: + return int(cleaned) + except ValueError: + return None + \ No newline at end of file diff --git a/task-2/AI_DEBUG.md b/task-2/AI_DEBUG.md index 413b94a..8276080 100644 --- a/task-2/AI_DEBUG.md +++ b/task-2/AI_DEBUG.md @@ -9,21 +9,46 @@ Document one debugging session you had during Task 1 where you used an LLM ## The Error - +During Task 1, my first version of `clean_salary` removed commas but did not safely handle invalid salary values. ## The Prompt - +I'm cleaning salary values from a CSV. + +The inputs can look like "85000", " 95000", '"68,000"', "N/A", or empty strings. +I want to return an int when possible, or None for missing/invalid values. + +Is this function safe, or could it crash on certain inputs? + +```python +def clean_salary(raw: str) -> int | None: + cleaned = raw.strip().replace(",", "") + if not cleaned or cleaned.upper() == "N/A": + return None + return int(cleaned) +``` ## The Solution - +ChatGPT explained that my function could crash because int(cleaned) was not inside a try/except block. It also pointed out that I should remove quote characters as well as commas. + +the suggested fix: + +```python +def clean_salary(raw: str) -> int | None: + cleaned = raw.strip() + + if not cleaned or cleaned.upper() == "N/A": + return None + + cleaned = cleaned.replace('"', "").replace(",", "") + + try: + return int(cleaned) + except ValueError: + return None +``` ## Reflection - +understand why the original code was broken. The CSV values are strings, and not every salary string can safely be converted directly with int(). Values like "68,000", N/A, empty strings, or unexpected formats can cause problems. Next time, I would test my helper function with several messy examples before running the full script, especially when converting strings into numbers. diff --git a/task-3/avatar&email.png b/task-3/avatar&email.png new file mode 100644 index 0000000..9a53503 Binary files /dev/null and b/task-3/avatar&email.png differ diff --git a/task-3/rg-hyf-students-readonly.png b/task-3/rg-hyf-students-readonly.png new file mode 100644 index 0000000..b3ef1ff Binary files /dev/null and b/task-3/rg-hyf-students-readonly.png differ diff --git a/task-3/the directory switcher.png b/task-3/the directory switcher.png new file mode 100644 index 0000000..e5e50dd Binary files /dev/null and b/task-3/the directory switcher.png differ