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/__pycache__/utils.cpython-311.pyc b/task-1/src/__pycache__/utils.cpython-311.pyc new file mode 100644 index 0000000..11f8f11 Binary files /dev/null and b/task-1/src/__pycache__/utils.cpython-311.pyc differ diff --git a/task-1/src/cleaner.py b/task-1/src/cleaner.py index 98e4985..9ece575 100644 --- a/task-1/src/cleaner.py +++ b/task-1/src/cleaner.py @@ -20,6 +20,7 @@ log = logging.getLogger(__name__) + def clean_row(row: dict[str, str]) -> dict | None: """Clean a single CSV row. Return None to skip the row (validation failed).""" name = clean_name(row.get("name", "")) diff --git a/task-1/src/utils.py b/task-1/src/utils.py index 2762398..9e76b52 100644 --- a/task-1/src/utils.py +++ b/task-1/src/utils.py @@ -13,6 +13,9 @@ def clean_name(raw: str) -> str: Returns the cleaned string. An empty input returns "". """ + if raw is None: + return "" + return raw.strip() raise NotImplementedError("Implement clean_name (Task 1)") @@ -21,6 +24,9 @@ def clean_email(raw: str) -> str: Returns the cleaned string. An empty input returns "". """ + if raw is None: + return "" + return raw.lower().strip() raise NotImplementedError("Implement clean_email (Task 1)") @@ -29,6 +35,12 @@ def clean_department(raw: str) -> str: Strip whitespace; treat empty string as missing. """ + if raw is None: + return "Unknown" + department = raw.strip() + if department =="": + return "Unknown" + return department raise NotImplementedError("Implement clean_department (Task 1)") @@ -38,4 +50,19 @@ 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"). """ + if raw is None: + return None + + salary = raw.strip() + + salary = salary.replace('"','').replace(',','') + + if salary =="" or salary == "N/A": + return None + + try: + return int(salary) + except ValueError: + return None + raise NotImplementedError("Implement clean_salary (Task 1)") diff --git a/task-2/AI_DEBUG.md b/task-2/AI_DEBUG.md index 413b94a..b3637a5 100644 --- a/task-2/AI_DEBUG.md +++ b/task-2/AI_DEBUG.md @@ -11,19 +11,57 @@ Document one debugging session you had during Task 1 where you used an LLM +Traceback (most recent call last): + File "/Users/barbari/Desktop/c55-data-week1/task-1/src/cleaner.py", line 17, in + from utils import clean_department, clean_email, clean_name, clean_salary + File "/Users/barbari/Desktop/c55-data-week1/task-1/src/utils.py", line 65 + expect ValueError: + ^^^^^^ ## The Prompt +I paseted the following error and code : + +I am getting an error in my Python script. +What is the problem +This is the code : + +try: + return int(salary) +expect ValueError: + return None + ## The Solution +The problem is a simple typo in your exception handling: + +expect ValueError: + +should be: + +except ValueError: +So your corrected code is: + +try: + return int(salary) +except ValueError: + return None + +That’s it—except is the correct Python keyword. + +yes it worked immediatly ## Reflection +yes, the real issue was a syntax error. python doesnt recognize expect, only except so the code coudnt run at all . +next time i will focus on the syntax . + + diff --git a/task-3/azure_proof.png b/task-3/azure_proof.png new file mode 100644 index 0000000..a0521f1 Binary files /dev/null and b/task-3/azure_proof.png differ