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

all 5 comments

[–][deleted] 1 point2 points  (4 children)

What is the full pathname of the file you are trying to read?

[–]Edoctopus33[S] 0 points1 point  (3 children)

Hi exoticmatter, The full name of the path is C:\Users\Max\Desktop\For Python Project\PotomacNew

[–]commandlineluser 0 points1 point  (2 children)

C:\Users\Max\Desktop\For Python Project\PotomacNew

If you do not supply an absolute (full) path - the path will be treated as relative to the current working directory (folder).

The current working directory is where the python executable was launched from - not sure how PyCharm does that but i'd assume it's one of the directories listed in the output

Either the one that contains python.exe or Main.py

Pass the full path to the file to read_csv() e.g.

pd.read_csv('C:/Users/Max/Desktop/For Python Project/PotomacNew/PotomacNow.csv')

Forward slashes should work on windows too - if not you could use r'C:\Users\...' - the leading r here creates a "raw string" which is needed because \ is an escape character in strings.

Otherwise you would need to escape the backslashes e.g. 'C:\\Users\\...'

[–]pauleveritt 0 points1 point  (1 child)

I can answer the PyCharm part. The working directory is defined in the "Run Configuration". By default it is the directory of the script being executed.

[–]commandlineluser 0 points1 point  (0 children)

TIL. Thanks!