Skip to content

read_csv throws wrong exception on permissions issue #23784

Closed
@omri374

Description

@omri374

Code Sample, a copy-pastable example if possible

# Your code here
train_df = pd.read_csv("../input/train.csv")

Problem description

When trying to open a CSV with no permissions on ubuntu 16.04, pandas returns this error:
OSError: Initializing from file failed

see this SO thread: https://stackoverflow.com/questions/50552404/oserror-initializing-from-file-failed-on-csv-in-pandas for an example.

Expected Output

Expected exception or details of exception should specify that this is a permission error, e.g. PermissionError and not OSError.

Output of pd.show_versions()

[paste the output of pd.show_versions() here below this line]

INSTALLED VERSIONS

commit: None
python: 3.6.7.final.0
python-bits: 64
OS: Linux
OS-release: 4.15.0-39-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8

pandas: 0.23.4
pytest: None
pip: 18.1
setuptools: 40.5.0
Cython: None
numpy: 1.15.4
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 7.1.1
sphinx: None
patsy: None
dateutil: 2.7.5
pytz: 2018.7
blosc: None
bottleneck: None
tables: None
numexpr: None
feather: None
matplotlib: None
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: None
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: None
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

Metadata

Metadata

Labels

Error ReportingIncorrect or improved errors from pandasIO CSVread_csv, to_csv

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions