1

I have a script for importing the contents of csv files in to a database. But when I try

filepath = '/Users/mc_kaiser/Desktop/Foo\ 020218-021318.csv'
test = open(filepath)

I get an IOError:

IOError: [Errno 2] No such file or directory: '/Users/mc_kaiser/Desktop/Foo\\ 020218-021318.csv'

I looked at this SO post and tried some of the answers, but it's Windows specific and didn't answer my question. Thank you!

1
  • Did filepath = '/Users/mc_kaiser/Desktop/Foo 020218-021318.csv' not work? (Without the '\') Commented Feb 14, 2018 at 20:57

1 Answer 1

2

That \ for escape is only used by shell, not part of the file name. In Python, just use:

filepath = '/Users/mc_kaiser/Desktop/Foo 020218-021318.csv'
Sign up to request clarification or add additional context in comments.

Comments

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.