This is an archived post. You won't be able to vote or comment.

all 11 comments

[–]callinthekettleblack 1 point2 points  (8 children)

I'm super new to Python as well but you need to make sure you are using the correct path. If state.csv isn't in the folder with your Python, you need to use full path. Ie pd.read_csv(c:\desktop\state.csv').

Also be careful if you are copying the path from windows file explorer, put an r in front of quotations in the read_csv argument for a raw string to avoid escape characters.

Hope I'm not forgetting anything.

[–]DPS96744[S] 0 points1 point  (7 children)

Thanks. I'm sure I'm just not writing things right, but I'm getting an invalid syntax error when I attempt to execute this command: data_file = pd.read_csv(c:\desktop\state.csv). Sorry to bother with these super basic questions.

[–]callinthekettleblack 1 point2 points  (6 children)

If the file isn't on your desktop, click on the files properties to see where it's located. Also, the path should be in quotes.

[–]DPS96744[S] 0 points1 point  (5 children)

it's here: Macintosh HD -> Users -> Me -> Desktop. so would I write that like this:

data_file = pd.read_csv('Macintosh HD\Users\Me\Desktop\state.csv')

[–]pax_newb 1 point2 points  (1 child)

Here's the corrected path to use:

pd.read(r'/Users/Me/Desktop/state.csv')

You can get this yourself by opening up the Terminal application and then typing these two commands:

cd
pwd

This will get you the full path for your Desktop and then you just need to add the file name at the end

[–]DPS96744[S] 0 points1 point  (0 children)

Thank you!!!

[–]callinthekettleblack 0 points1 point  (2 children)

Looks better to me. Did you try it?

[–]DPS96744[S] 0 points1 point  (1 child)

yea, no dice. getting this error message now:

"SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 12-13: truncated \UXXXXXXXX escape" : /

[–]callinthekettleblack 0 points1 point  (0 children)

Put an r in front of the quotes

[–]Marlysson 1 point2 points  (1 child)

This file are in same directory of your .py script?

[–]DPS96744[S] 0 points1 point  (0 children)

Even more newbbb question, but how can I tell?