Opening file from a Fileshare-system with python
<p>im trying to open a file from a Filesharing-System of our company. Here is the Code of the script:</p>

<pre><code>import sys
import xlrd
from tkinter import *
import pandas as pd
import time
from os import *

#hvl_file_path = filedialog.askopenfilename()
save_path = filedialog.asksaveasfilename(initialdir="C:/", defaultextension=".xlsx")


t1 = time.clock()
hvl = pd.read_csv('\\Q4DEE1SYVFS.ffm.t-systems.com\pasm$\Berichte_SQL\HVL.csv', sep='|', encoding='latin1', low_memory=False)
hvl.to_excel(save_path, index=False)
t2 = time.clock()
t_ges = t2 - t1
print(t_ges)
</code></pre>

<p>You can see the file_path is: \Q4DEE1SYVFS.ffm.t-systems.com\pasm$\Berichte_SQL\HVL.csv</p>

<p>When i start the script i get the following error:</p>

<pre><code>Traceback (most recent call last):
  File "C:/Users/A52113242/Desktop/PROJEKTE/[INPROGRESS] AUSWERTUNG COIN + HVL/hvl_convert.py", line 13, in &lt;module&gt;
    hvl = pd.read_csv('Q4DEE1SYVFS.ffm.t-systems.com\pasm$\Berichte_SQL\HVL.csv', sep='|', encoding='latin1', low_memory=False)
  File "C:\Users\A52113242\AppData\Local\Downloaded Apps\Winpython\python-3.4.3\lib\site-packages\pandas\io\parsers.py", line 474, in parser_f
    return _read(filepath_or_buffer, kwds)
  File "C:\Users\A52113242\AppData\Local\Downloaded Apps\Winpython\python-3.4.3\lib\site-packages\pandas\io\parsers.py", line 250, in _read
    parser = TextFileReader(filepath_or_buffer, **kwds)
  File "C:\Users\A52113242\AppData\Local\Downloaded Apps\Winpython\python-3.4.3\lib\site-packages\pandas\io\parsers.py", line 566, in __init__
    self._make_engine(self.engine)
  File "C:\Users\A52113242\AppData\Local\Downloaded Apps\Winpython\python-3.4.3\lib\site-packages\pandas\io\parsers.py", line 705, in _make_engine
    self._engine = CParserWrapper(self.f, **self.options)
  File "C:\Users\A52113242\AppData\Local\Downloaded Apps\Winpython\python-3.4.3\lib\site-packages\pandas\io\parsers.py", line 1072, in __init__
    self._reader = _parser.TextReader(src, **kwds)
  File "pandas\parser.pyx", line 350, in pandas.parser.TextReader.__cinit__ (pandas\parser.c:3187)
  File "pandas\parser.pyx", line 594, in pandas.parser.TextReader._setup_parser_source (pandas\parser.c:5930)
OSError: File b'Q4DEE1SYVFS.ffm.t-systems.com\\pasm$\\Berichte_SQL\\HVL.csv' does not exist
</code></pre>

<p>So my question is if there is a problem with the path or its a point of missing permissions. Do you have any ideas?</p>

<p>Thank you!</p>

<p>EDIT:</p>

<p>Now i tried to open the file: </p>

<pre><code>f = open('\\Q4DEE1SYVFS.ffm.t-systems.com\pasm$\RFM\Berichte_SQL\HVL.csv','w')
</code></pre>

<p>After trying to open the file with open i get this error: </p>

<pre><code>Traceback (most recent call last):
  File "C:/Users/A52113242/Desktop/PROJEKTE/[INPROGRESS] AUSWERTUNG COIN + HVL/hvl_convert.py", line 13, in &lt;module&gt;
    f = open('\\Q4DEE1SYVFS.ffm.t-systems.com\pasm$\Berichte_SQL\HVL.csv','w')
TypeError: an integer is required (got type str)
</code></pre>

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

<pre><code>pd.read_csv(r'\\Q4DEE1SYVFS.ffm ...')
</code></pre>

<p>not doing that result in some chars to be interpreted:</p>

<pre><code>print("foo\test")
</code></pre>

<p>yields:</p>

<pre><code>foo est   (tabulation has been inserted)
</code></pre>

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

<p>Double antislashes means "escape the antislash" and is converted a single backslash.</p>

<pre><code>print('\\ddd')
</code></pre>

<p>yields:</p>

<pre><code>\ddd
</code></pre>

<p>thus your path is incorrect.</p>

<p>But there's more here. You shouldn't get <code>expected int found str</code> 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:</p>

<pre><code>&gt;&gt;&gt; z=r"\\Q4DEE1SYVFS.ffm.t-systems.com\pasm$\Berichte_SQL\HVLââ.csv"
&gt;&gt;&gt; z
'\\\\Q4DEE1SYVFS.ffm.t-systems.com\\pasm$\\Berichte_SQL\\HVL\xe2\x80\x8c\xe2\x80\x8b.csv'
</code></pre>

<p>Just rewrite the last part of your string and it will work.</p>

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

python pandas