loadtxt error
Title
Question
In [47]: !type D:\python\Python\28fs385.txt
57.6
64
70.4
60.8
In [48]: z=loadtxt("D:\python\Python\28fs385.txt")
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-48-3b2437862d37> in <module>
----> 1 z=loadtxt("D:\python\Python\28fs385.txt")
c:\users\manda\appdata\local\programs\python\python38\lib\site-packages\numpy\lib\npyio.py in loadtxt(fname, dtype, comments, delimiter, converters, skiprows, usecols, unpack, ndmin, encoding, max_rows)
979 fname = os_fspath(fname)
980 if _is_string_like(fname):
--> 981 fh = np.lib._datasource.open(fname, 'rt', encoding=encoding)
982 fencoding = getattr(fh, 'encoding', 'latin1')
983 fh = iter(fh)
c:\users\manda\appdata\local\programs\python\python38\lib\site-packages\numpy\lib\_datasource.py in open(path, mode, destpath, encoding, newline)
267
268 ds = DataSource(destpath)
--> 269 return ds.open(path, mode, encoding=encoding, newline=newline)
270
271
c:\users\manda\appdata\local\programs\python\python38\lib\site-packages\numpy\lib\_datasource.py in open(self, path, mode, encoding, newline)
621 encoding=encoding, newline=newline)
622 else:
--> 623 raise IOError("%s not found." % path)
624
625
<span style="background-color: rgb(204, 204, 153);">
</span>
</span>
<span style="background-color: rgb(204, 204, 153);">OSError: D:\python\Python?8fs385.txt not found.</span>
<span style="background-color: rgb(204, 204, 153);">
</span>
</span>
<span style="background-color: rgb(204, 204, 153);">Why I am getting above error</span>
<span style="background-color: rgb(204, 204, 153);">
</span>
</span>
Python-3.4.3 Loading-Data-From-Files 02-03 min 10-20 sec
Answers:
Please use double backslashes:
Example: loadtxt("C:\\Users\\groenera\\Desktop\\file.csv")
Login to add comment