Skip to content Skip to sidebar Skip to footer

Opening File From A Fileshare-system With Python

im trying to open a file from a Filesharing-System of our company. Here is the Code of the script: import sys import xlrd from tkinter import * import pandas as pd import time from

Solution 1:

When dealing with UNC strings or Windows strings in general it is better to declare constant strings with the r (raw) prefix:

pd.read_csv(r'\\Q4DEE1SYVFS.ffm ...')

not doing that result in some chars to be interpreted:

print("foo\test")

yields:

foo est(tabulation has been inserted)

Same goes for many lowercase chars (`\t,\n,\v,\b,\x ...).

Double antislashes means "escape the antislash" and is converted a single backslash.

print('\\ddd')

yields:

\ddd

thus your path is incorrect.

But there's more here. You shouldn't get expected int found str errors. So I found out the problem in one of your comments: there are some invisible chars causing trouble. I pasted the path from your comments in pyscripter and assigned it to a variable and go this:

>>>z=r"\\Q4DEE1SYVFS.ffm.t-systems.com\pasm$\Berichte_SQL\HVL‌​.csv">>>z
'\\\\Q4DEE1SYVFS.ffm.t-systems.com\\pasm$\\Berichte_SQL\\HVL\xe2\x80\x8c\xe2\x80\x8b.csv'

Just rewrite the last part of your string and it will work.

PS: notepad++ was unable to see the weird chars. I heard that SciTe had a tendency to let those pass too. Pyscripter sees them.

Post a Comment for "Opening File From A Fileshare-system With Python"