Skip to content

Commit 5e52171

Browse files
Merge pull request #22 from Shreyanshi210205/shreyanshi_log
feat: improve error handling and logging in extract function
2 parents 06556d6 + 8681ce7 commit 5e52171

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

app/etl/extract.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,16 @@ def extract(path: str = "xyz.csv") -> ________: # TODO (Find & Fix)
3434
# TODO (Find & Fix)
3535
pass
3636
except UnicodeDecodeError:
37-
# TODO (Find & Fix)
38-
pass
37+
print(f"Failed to read with encoding '{encoding}'") # Log the encoding that failed
3938

4039
if df is None:
41-
# TODO (Find & Fix)
42-
pass
40+
raise ValueError(f" Could not read CSV with tried encodings: {encodings}")
4341

4442
# Validate data
4543
if df.empty:
46-
# TODO (Find & Fix)
47-
pass
44+
raise ValueError("File contains no data")
4845

49-
print(f"✅ Extracted {len(df)} rows and {len(df.columns)} columns") # TODO (Find & Fix): Use logging instead of print
46+
print(f"✅ Extracted {len(df)} rows and {len(df.columns)} columns") # TODO: Use logging instead of print
5047
return df
5148

5249
except pd.errors.EmptyDataError:

0 commit comments

Comments
 (0)