I’m currently studying the Credit Risk Modeling in Python. In the general preprocessing section class, I found a message error when importing data into my python. I found the right document from Q&A section you provided to other candidates.
- 1 – I had a “file not found” error, which I was able to solve by replacing the name of the file (saved in a different directory) by writing the absolute path. With its full name it does not work wherever i save the doc (I use 2 different hard drive)
- I now face this below error : “OSError: Initializing from file failed” (code below)
- Also note that I tried with read_excel and it gives : PermissionError: [Errno 13] Permission denied: ‘D:/Python_dataset’.
I’m very confused so if you can help me, please advise. I really want to get through this with you. Thanks a lot 🙂
Here is the code :
>import numphy as np
import pandas as pd
>loan_data_backup_2007_2014 = pd.read_csv(“D:/Python_dataset”)
--------------------------------------------------------------------------- OSError Traceback (most recent call last) <ipython-input-2-771ff0942c98> in <module> ----> 1 loan_data_backup_2007_2014 = pd.read_csv('C:/Users/tom-5/Downloads') 2 print(data) D:\Anaconda Python\lib\site-packages\pandas\io\parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, skipfooter, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, cache_dates, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, doublequote, escapechar, comment, encoding, dialect, error_bad_lines, warn_bad_lines, delim_whitespace, low_memory, memory_map, float_precision) 674 ) 675 --> 676 return _read(filepath_or_buffer, kwds) 677 678 parser_f.__name__ = name D:\Anaconda Python\lib\site-packages\pandas\io\parsers.py in _read(filepath_or_buffer, kwds) 446 447 # Create the parser. --> 448 parser = TextFileReader(fp_or_buf, **kwds) 449 450 if chunksize or iterator: D:\Anaconda Python\lib\site-packages\pandas\io\parsers.py in __init__(self, f, engine, **kwds) 878 self.options["has_index_names"] = kwds["has_index_names"] 879 --> 880 self._make_engine(self.engine) 881 882 def close(self): D:\Anaconda Python\lib\site-packages\pandas\io\parsers.py in _make_engine(self, engine) 1112 def _make_engine(self, engine="c"): 1113 if engine == "c": -> 1114 self._engine = CParserWrapper(self.f, **self.options) 1115 else: 1116 if engine == "python": D:\Anaconda Python\lib\site-packages\pandas\io\parsers.py in __init__(self, src, **kwds) 1889 kwds["usecols"] = self.usecols 1890 -> 1891 self._reader = parsers.TextReader(src, **kwds) 1892 self.unnamed_cols = self._reader.unnamed_cols 1893 pandas\_libs\parsers.pyx in pandas._libs.parsers.TextReader.__cinit__() pandas\_libs\parsers.pyx in pandas._libs.parsers.TextReader._setup_parser_source() OSError: Initializing from file failed
First, thank you for the detailed error report.
Second, Permission Error 13 relates to the fact that your user profile does not have sufficient permissions. In that case – to access the file directories.
The easiest way to fix that is to launch Jupyter as an administrator.
If however, this does not work, we will look into more complex ways to bypass this.
Thanks for your anwser.
This still does not work. The file is a csv type anyways.
So in the "OSError: Initializing from file failed", "#Create the parser" is highlighted in red.
May this be something of importance? Not very familiar with this to be honest.
Myself also faced similar issue. Please open the CSV file, CSV file itself does not contain the expected data. Download this data from kaggle