# Unable to import csv file in jupyter note book

**URL:** https://discourse.jupyter.org/t/unable-to-import-csv-file-in-jupyter-note-book/19981
**Category:** General
**Tags:** how-to, help-wanted
**Created:** [June 18, 2023, 8:29am UTC](https://discourse.jupyter.org/t/unable-to-import-csv-file-in-jupyter-note-book/19981 "2023-06-18T08:29:52Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Irfan\_Ansari](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/irfan_ansari/32/10228_2.png) [@Irfan\_Ansari](https://discourse.jupyter.org/u/Irfan_Ansari)
#### Post date: [June 18, 2023, 8:29am UTC](https://discourse.jupyter.org/t/unable-to-import-csv-file-in-jupyter-note-book/19981/1 "2023-06-18T08:29:52Z")

</div>

Hi,  
It has been 3 days I have tried to import csv file and still not completed successfully.  
I have watched YouTube videos, google, ChatGPT, bard all the things I have tried  
please help me plzzzzzzzzzzzzzzzzzzzzzzzzzzzz.

* * *

FileNotFoundError Traceback (most recent call last)  
Cell In[9], line 1  
----\> 1 df = pd.read\_csv(“Desktop/IrfanPython/IrfanPython/wrf.csv”)

File ~\anaconda3\lib\site-packages\pandas\util\_decorators.py:211, in deprecate\_kwarg..\_deprecate\_kwarg..wrapper(\*args, \*\*kwargs)  
209 else:  
210 kwargs[new\_arg\_name] = new\_arg\_value  
 → 211 return func(\*args, \*\*kwargs)

File ~\anaconda3\lib\site-packages\pandas\util\_decorators.py:331, in deprecate\_nonkeyword\_arguments..decorate..wrapper(\*args, \*\*kwargs)  
325 if len(args) \> num\_allow\_args:  
326 warnings.warn(  
327 msg.format(arguments=\_format\_argument\_list(allow\_args)),  
328 FutureWarning,  
329 stacklevel=find\_stack\_level(),  
330 )  
 → 331 return func(\*args, \*\*kwargs)

File ~\anaconda3\lib\site-packages\pandas\io\parsers\readers.py:950, in read\_csv(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, encoding\_errors, dialect, error\_bad\_lines, warn\_bad\_lines, on\_bad\_lines, delim\_whitespace, low\_memory, memory\_map, float\_precision, storage\_options)  
935 kwds\_defaults = \_refine\_defaults\_read(  
936 dialect,  
937 delimiter,  
(…)  
946 defaults={“delimiter”: “,”},  
947 )  
948 kwds.update(kwds\_defaults)  
 → 950 return \_read(filepath\_or\_buffer, kwds)

File ~\anaconda3\lib\site-packages\pandas\io\parsers\readers.py:605, in \_read(filepath\_or\_buffer, kwds)  
602 \_validate\_names(kwds.get(“names”, None))  
604 # Create the parser.  
 → 605 parser = TextFileReader(filepath\_or\_buffer, \*\*kwds)  
607 if chunksize or iterator:  
608 return parser

File ~\anaconda3\lib\site-packages\pandas\io\parsers\readers.py:1442, in TextFileReader. **init** (self, f, engine, \*\*kwds)  
1439 self.options[“has\_index\_names”] = kwds[“has\_index\_names”]  
1441 self.handles: IOHandles | None = None  
 → 1442 self.\_engine = self.\_make\_engine(f, self.engine)

File ~\anaconda3\lib\site-packages\pandas\io\parsers\readers.py:1735, in TextFileReader.\_make\_engine(self, f, engine)  
1733 if “b” not in mode:  
1734 mode += “b”  
 → 1735 self.handles = get\_handle(  
1736 f,  
1737 mode,  
1738 encoding=self.options.get(“encoding”, None),  
1739 compression=self.options.get(“compression”, None),  
1740 memory\_map=self.options.get(“memory\_map”, False),  
1741 is\_text=is\_text,  
1742 errors=self.options.get(“encoding\_errors”, “strict”),  
1743 storage\_options=self.options.get(“storage\_options”, None),  
1744 )  
1745 assert self.handles is not None  
1746 f = self.handles.handle

File ~\anaconda3\lib\site-packages\pandas\io\common.py:856, in get\_handle(path\_or\_buf, mode, encoding, compression, memory\_map, is\_text, errors, storage\_options)  
851 elif isinstance(handle, str):  
852 # Check whether the filename is to be opened in binary mode.  
853 # Binary mode does not support ‘encoding’ and ‘newline’.  
854 if ioargs.encoding and “b” not in ioargs.mode:  
855 # Encoding  
 → 856 handle = open(  
857 handle,  
858 ioargs.mode,  
859 encoding=ioargs.encoding,  
860 errors=errors,  
861 newline=“”,  
862 )  
863 else:  
864 # Binary mode  
865 handle = open(handle, ioargs.mode)

FileNotFoundError: [Errno 2] No such file or directory: ‘Desktop/IrfanPython/IrfanPython/wrf.csv’

---

<div class="post-metadata">

### Author: ![fomightez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fomightez/32/495_2.png) [@fomightez](https://discourse.jupyter.org/u/fomightez)
#### Post date: [June 18, 2023, 1:57pm UTC](https://discourse.jupyter.org/t/unable-to-import-csv-file-in-jupyter-note-book/19981/2 "2023-06-18T13:57:21Z")

</div>

Have you tried using the documentation for Pandas to make a toy dataframe and save that as `.csv` file like `df.to_csv('my_csv.csv.')` (purposefully no complicated path), and then reopened it?  
Can then you use your system’s graphical user interface to move the file you are trying to work with to the same place and see if you can open it just using the file name?

It looks like a typical path problem. From inside Jupyter can you see that file and navigate to it properly using `pwd` and `ls` and `%cd`? (Note you have to use the magic version of cd to change the directory and have it take effect beyond that single line.) Explore using those to navigate your system’s hierarchy from inside Jupyter and see if you can get there. (That advice is in expanded form [here](https://discourse.jupyter.org/t/convert-from-py-to-ipynb-format/9993/4) if that is unclear.)

Are you using OneDrive? That puts files in places that aren’t always clear to the user.

---

<div class="post-metadata">

### Author: ![Irfan\_Ansari](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/irfan_ansari/32/10228_2.png) [@Irfan\_Ansari](https://discourse.jupyter.org/u/Irfan_Ansari)
#### Post date: [June 18, 2023, 3:43pm UTC](https://discourse.jupyter.org/t/unable-to-import-csv-file-in-jupyter-note-book/19981/3 "2023-06-18T15:43:13Z")

</div>

it’s not working.  
df.write\_csv(‘Desktop/IrfanPython/IrfanPython/wrf.csv’)

could you please connect with me for 5 min  
whenever you will be free  
[8809968819i@gmail.com](mailto:8809968819i@gmail.com)

---

<div class="post-metadata">

### Author: ![fomightez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fomightez/32/495_2.png) [@fomightez](https://discourse.jupyter.org/u/fomightez)
#### Post date: [June 18, 2023, 6:05pm UTC](https://discourse.jupyter.org/t/unable-to-import-csv-file-in-jupyter-note-book/19981/4 "2023-06-18T18:05:46Z")

</div>

> [@Irfan\_Ansari](#):
>
> it’s not working.  
> df.write\_csv(‘Desktop/IrfanPython/IrfanPython/wrf.csv’)

That isn’t what I suggested you do. Don’t put anything in front of the file name and try to save it and then work from there. (Plus I had the syntax wrong. I had got distracted and hit send before I confirmed what it was. I edited now; it is `df.to_csv('my_csv.csv') `. And make sure you have a dataframe defined first. The Pandas documentation offers lots of examples.) The point is to keep it super simple and see what works. You already knew from your previous post that the path you had was a problem. So by still complicating it, you wouldn’t be learning much.

---

<div class="post-metadata">

### Author: ![Irfan\_Ansari](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/irfan_ansari/32/10228_2.png) [@Irfan\_Ansari](https://discourse.jupyter.org/u/Irfan_Ansari)
#### Post date: [June 19, 2023, 1:27pm UTC](https://discourse.jupyter.org/t/unable-to-import-csv-file-in-jupyter-note-book/19981/5 "2023-06-19T13:27:10Z")

</div>

sir I am using MS Office 2007 version,  
do you think , it may be the reason of not importing csv file in jupyter notebook???

---

<div class="post-metadata">

### Author: ![fomightez](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/fomightez/32/495_2.png) [@fomightez](https://discourse.jupyter.org/u/fomightez)
#### Post date: [June 19, 2023, 2:47pm UTC](https://discourse.jupyter.org/t/unable-to-import-csv-file-in-jupyter-note-book/19981/6 "2023-06-19T14:47:21Z")

</div>

I’m not understanding why MS Office 2007 version being involved would make a difference. If you are really making a pure text based `.csv` then it should work. There are ways to save those from in Excel but they are not the default ways. You can check though with a standard coding text editor like VSCode or SublimeText if it is in face a pure text file that is comma-separated values? Also you can obtain several examples of comma separated value files on GitHub and if those work and yours doesn’t, then likely you are on the right track about considering how you are making your CSV file.

---

<div class="post-metadata">

### Author: ![Om\_Chitmalwar](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/om_chitmalwar/32/12765_2.png) [@Om\_Chitmalwar](https://discourse.jupyter.org/u/Om_Chitmalwar)
#### Post date: [March 17, 2024, 12:20pm UTC](https://discourse.jupyter.org/t/unable-to-import-csv-file-in-jupyter-note-book/19981/7 "2024-03-17T12:20:51Z")

</div>

you can try this  
df\_2 = pd.read\_csv(r’file path’)
