What are all the exceptions that can be thrown by pd.read_csv()?
In the example below I am capturing some exception types explicitly and using a generic Exception to catch the others, but what are the others exactly?
Reviewing the documentation for pandas read_csv() I can't see a complete list of exceptions thrown.
In a more general case, what is the recommended practice to determine all of the types of exceptions that can be thrown by any call/library?
import pandas as pd
try:
df = pd.read_csv("myfile.csv")
except FileNotFoundError:
print("File not found.")
except pd.errors.EmptyDataError:
print("No data")
except pd.errors.ParserError:
print("Parse error")
except Exception:
print("Some other exception")
.csv
extension. I would like to check if this is an eligible file to process considering content, encodings, separators, etc. Without the knowledge about the error, I would be forced to show a user very generic message.Copy permalink
when linking to files from VCS repositories. The link is dead now. Here is the current link that will show theto_csv
version at the time of posting unless the repo is cleaned: github.com/pandas-dev/pandas/blob/…