-2

a photo of using open() and pd.read_csv() to open a link but open() says no file directory, why do I have an error when I used open() but pd.read_csv opened the file, I tried using it again but it says file not found?

  • If you post images of code or error messages, please also copy/paste or type the actual code/message directly into the post. While images and screenshots can be helpful for providing context, the post should still be clear and useful without them. Please see [Why should I not upload images of code/data/errors when asking a question?](//meta.stackoverflow.com/a/285557/208273) Posts in which essential text is only included in images are likely to be closed for not having enough details. – Ryan M Sep 17 '22 at 06:21

1 Answers1

0

The function open() opens a file which resides in persistent memory (SSD/HDD), and returns a file object.

pandas.read_csv() can parse input directly from URLs.

In other words: Because the file, as the error says, does not exist and neither does a path to said file.

Edit: I just realized that you may be new here, so maybe I'll give an analogy: Imagine I told you to open a book, and said out loud a link to a book. You would wonder how you would ever open that book as well, because you have no way of parsing that information in your head. If I instead send a you link, which you open on your computer, you can read the file. open() wants a physical book. pd.read_csv() can also accept a link to the book.

JOKKINATOR
  • 356
  • 1
  • 11