0

Python rookie here. Trying to use the CSV module, but I get an error:

IOError: [Errno 2] No such file or directory: 'books.csv'

The actual CSV file is stored on my desktop. I suppose this means Python can't find the file? If so, how can I fix this?

Many thanks in advance!

3
  • Give it the full path to the file, or run the script in the same directory where the file is. Commented Nov 23, 2011 at 19:12
  • Are you specifying the absolute pathname of your csv file? Commented Nov 23, 2011 at 19:13
  • It never hurts to use raw strings while opening files: fo = open(r'X:\Loc\To\File', 'r') especially if you're using Windows. Commented Nov 23, 2011 at 19:45

1 Answer 1

3

Since your file name includes no path component, it is implicitly assigned to be in the current directory. Unless your current directory is the desktop, you won't be able to find the file.

Either give it a full pathname, or move to the desktop and run your script from there.

Sign up to request clarification or add additional context in comments.

1 Comment

Awesome! I simply moved the script to the desktop, and it works just fine. I had a feeling it the solution was very simple! Thanks guys!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.