0

I'm trying to load a csv into Phython 2 using Anaconda with the following code:

pd.read_csv('C:\Users\thakuar1\Desktop\Machine_Learning\at_LoanStats3a_20170620_v12.csv')

but keep running into the below error:

IOError: File C:\Users  hakuar1\Desktop\Machine_Learningt_LoanStats3a_20170620_v12.csv does not exist

Any reason why the filepath would be dropping characters?

Thanks!

1

2 Answers 2

1

Any reason why the filepath would be dropping characters?

\t stands for a TAB space, be sure to escape that string by writing it with double slash \\, see the docs to know more about escaping characters.

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

1 Comment

Great! Then you should accept this answer, so other users know this was the solution. Also, remember to upvote of you found this useful
0

The back slash is an escape character. The best approach is to build the path with the os.path module since it will work across different OSs. But you can simply use a raw string to ignore escape characters.

pd.read_csv(r'...')

1 Comment

I tried the double back slash instead and that worked. I will try this also and see if this does the job too. Thanks!

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.