PowerBI Python Script Error

Hi All,

I’m in the process of completing the course Python I for Power BI Users .

Error faced when importing data in PBI using Python script - Power BI - Enterprise DNA Forum

However I’m having similar issues as the OP on the above post but the solution does not work.

I suspect the error pops up as I have a space in the path. If this is the case would like to know how i can change environment directories?

image

image

Thanks

@adsa ,

Sorry, don’t know the answer to this one, but looping in @gmh1977 , @gjmount , @AntrikshSharma , and @Greg, who all know Python and hopefully can help you with this one.

  • Brian

@adsa Backslash is an escape sequence in Python, so either you need to write the path like this:

df = pd.read_csv(r"C:\Users\Antriksh\OneDrive\Desktop\Antriksh's\test.txt")

or

df = pd.read_csv("C:\\Users\\Antriksh\\OneDrive\\Desktop\\Antriksh's\\test.txt")

1 Like

@AntrikshSharma Thanks for the response.

I’ve tried both the solutions you suggested still having the same error

image

image

@AntrikshSharma,

Tried that method as well and it did not work.

After a few hours of playing around and running it on my laptop it worked. The problem was in fact the spacing in the file path (See pic below). Some reason it does not play nice if detects a space. I rectified this my creating a new user profile :frowning:

image

Output: