File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed
Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -34,24 +34,21 @@ 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 :
5350 raise ValueError ("❌ File contains no data" )
5451 except pd .errors .ParserError as e :
5552 raise ValueError (f"❌ Error parsing CSV: { e } " )
5653 except Exception as e :
57- raise ValueError (f"❌ Unexpected error reading file: { e } " )
54+ raise ValueError (f"❌ Unexpected error reading file: { e } " )
You can’t perform that action at this time.
0 commit comments