FileNotFoundError Appears When Chdir in Python

Asked 2 months ago, Updated 2 months ago, 3 views

Currently, I want to read the csv file in python, but the error below appears and I cannot proceed.
Please tell me how to deal with it

importos

print(os.getcwd())
# Check the current directory ↑

import pandas aspd
os.chdir("c:/home2/1851068h/Desktop/python/0000.csv")
FileNotFoundError Traceback (most recent call last)
<ipython-input-17-9f3ecf581f47>in<module>
---->1os.chdir("c:/home2/1851068h/Desktop/python/0000.csv")

FileNotFoundError: [Errno2] No such file or directory: 'c:/home2/1851068h/Desktop/python/0000.csv'

Enter a description of the image here

python csv

2022-09-30 11:10

1 Answers

os.chdir() moves directories and should not be specified.
Remove the 0000.csv part and specify only the pathname of the directory.

Also, the path name displayed in os.getcwd() and the path name specified in os.chdir() are not balanced (with or without "c:"). Is that okay?
I think it's better to adjust that.

Basic Python Introductory Directory Operations (1/3)
See the Get Current Directory section of the article above.

I may have something to do with the comments.
How to load the csv file in the jupyter notebook

One thing to keep in mind is to import files from jupyter to upload.

I couldn't get csv even if I specified the path of the file on my desktop, so I fell in love with it for a few hours.

However, there are comments like this.

If you specify an absolute path, you can retrieve csv anywhere in the local area


2022-09-30 11:10

If you have any answers or tips


© 2022 OneMinuteCode. All rights reserved.