Scarface
Scarface

Reputation: 407

Error while accessing a file in a path using openpyxl python module

I'm using openpyxl module in python to access a file in a path. But my file path looks like below and it is on network drive

"\\rsc.secad.com\hdrive\shared\test.xlsx"

To escape '\\' backslashes in above path I have added \ to it ,as shown in below code.

from openpyxl import load_workbook
fp = "\\\rsc.secad.com\\hdrive\\shared\\test.xlsx"
wb = load_workbook(fp)

And when I ran the program, I got following error.

OSError: [Errno 22] Invalid argument:"\\\rsc.secad.com\\hdrive\\shared\\test.xlsx"

Is there any way to access the path with double backslashes in it using openpyxl ?

Upvotes: 0

Views: 1587

Answers (1)

Shiv
Shiv

Reputation: 151

Well, you could simply use the forward slash instead like this

fp = "//rsc.secad.com/hdrive/shared/test.xlsx"

Upvotes: 1

Related Questions