I'm having difficulty reading a csv file into the pandas data frame. I am a total newcomer to pandas, and this is preventing me from progressing. I have read the documentation and searched for solutions, but I am unable to proceed. I have tried the following to no avail...
import pandas as pd
import numpy as np
pd.read_csv('C:\Users\rcreedon\Desktop\TEST.csv')
pd.read_csv("C:\Users\rcreedon\Desktop\TEST.csv")
and similar permutations with/without quotation marks.
It spits out a large composite error that ends in:
IOError: File C:\Users
creedon\Desktop\TEST.csv does not exist
It seems strange that in the error it misses of the "r" from "rcreedon". Is this what's causing the problem?
Just for the sake of it i also tried
pd.read_csv('C:\rcreedon\Desktop\TEST.csv')
And again the 'r' was missed when the error was returned.
Sorry to be such a block head, but I'm struggling here....
Any help appreciated.
"\r" usually is interpreted as a special character and means carriage return. Either add a 'r' prefix to your string literals which prevents this special sequence from being interpreted (e.g. path = r"foo\rar"
), or, as already suggested, just use a normal slash as path delimiter. Python is intelligent enough for it to also work on Windows :-)
Just use a raw string:
pd.read_csv(r'C:\Users\rcreedon\Desktop\TEST.csv')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With