1
path = input("Enter the path")
book = xlrd.open_workbook(path)

After giving path and running program, I am getting the following error:

OSError: [Errno 22] Invalid argument: '"D:\\\shreyatest1.xlsx"'

Path is: "D:\\shreyatest1.xlsx"

9
  • 2
    Are you inputting it with double slashes? Commented Jun 3, 2016 at 12:44
  • Yes. And yet i am getting the error. Commented Jun 3, 2016 at 12:44
  • 1
    Dont do that, while inputting, use single slash only. Commented Jun 3, 2016 at 12:45
  • No luck :\ same error Commented Jun 3, 2016 at 12:46
  • Have you tried @Mureinik answer? That is what I meant. Commented Jun 3, 2016 at 12:47

1 Answer 1

1

The \\ character is how python represents an escaped \ in a string literal. When inputting a string from the console, there's no need (read: it's wrong) to use this notation. Just input the path as you see it - D:\shreyatest1.xlsx.

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

1 Comment

Worked. Thanks a lot! :)

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.