Other Types Of Plots
Title
Question
not able to execute cat command and loadtxt. I hadsame issue in basic video 8(loading dat from file).
In [45]: %pylab
Using matplotlib backend: TkAgg
Populating the interactive namespace from numpy and matplotlib
In [46]: cat company-a-dat.txt
File "<ipython-input-46-e95588f4945f>", line 1
cat company-a-dat.txt
^
SyntaxError: invalid syntax
In [47]: cat company-a-data.txt
File "<ipython-input-47-37dbbe0090a4>", line 1
cat company-a-data.txt
^
SyntaxError: invalid syntax
In [48]: cat company-a-data.txt
File "<ipython-input-48-37dbbe0090a4>", line 1
cat company-a-data.txt
^
SyntaxError: invalid syntax
In [49]: cat company-a-data.txt
File "<ipython-input-49-37dbbe0090a4>", line 1
cat company-a-data.txt
^
SyntaxError: invalid syntax
In [50]: year,profit=loadtxt('company-a-dat.txt)
File "<ipython-input-50-6c82ded6f088>", line 1
year,profit=loadtxt('company-a-dat.txt)
^
SyntaxError: EOL while scanning string literal
In [51]: year,profit=loadtxt('company-a-dat.txt')
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-51-9d4241c7c624> in <module>
----> 1 year,profit=loadtxt('company-a-dat.txt')
c:\users\admin\appdata\local\programs\python\python36\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\admin\appdata\local\programs\python\python36\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\admin\appdata\local\programs\python\python36\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
OSError: company-a-dat.txt not found.
In [52]: year,profit=loadtxt('company-a-data.txt')
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-52-b48e6119614d> in <module>
----> 1 year,profit=loadtxt('company-a-data.txt')
c:\users\admin\appdata\local\programs\python\python36\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\admin\appdata\local\programs\python\python36\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\admin\appdata\local\programs\python\python36\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
OSError: company-a-data.txt not found.
In [53]: year,profit=loadtxt('company-a-data.txt',unpack=true)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-53-de6020824536> in <module>
----> 1 year,profit=loadtxt('company-a-data.txt',unpack=true)
NameError: name 'true' is not defined
In [54]: year,profit=loadtxt('company-a-data.txt',unpack=True)
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-54-070812f8b62f> in <module>
----> 1 year,profit=loadtxt('company-a-data.txt',unpack=True)
c:\users\admin\appdata\local\programs\python\python36\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\admin\appdata\local\programs\python\python36\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\admin\appdata\local\programs\python\python36\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
OSError: company-a-data.txt not found.
In [55]:
In [45]: %pylab
Using matplotlib backend: TkAgg
Populating the interactive namespace from numpy and matplotlib
In [46]: cat company-a-dat.txt
File "<ipython-input-46-e95588f4945f>", line 1
cat company-a-dat.txt
^
SyntaxError: invalid syntax
In [47]: cat company-a-data.txt
File "<ipython-input-47-37dbbe0090a4>", line 1
cat company-a-data.txt
^
SyntaxError: invalid syntax
In [48]: cat company-a-data.txt
File "<ipython-input-48-37dbbe0090a4>", line 1
cat company-a-data.txt
^
SyntaxError: invalid syntax
In [49]: cat company-a-data.txt
File "<ipython-input-49-37dbbe0090a4>", line 1
cat company-a-data.txt
^
SyntaxError: invalid syntax
In [50]: year,profit=loadtxt('company-a-dat.txt)
File "<ipython-input-50-6c82ded6f088>", line 1
year,profit=loadtxt('company-a-dat.txt)
^
SyntaxError: EOL while scanning string literal
In [51]: year,profit=loadtxt('company-a-dat.txt')
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-51-9d4241c7c624> in <module>
----> 1 year,profit=loadtxt('company-a-dat.txt')
c:\users\admin\appdata\local\programs\python\python36\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\admin\appdata\local\programs\python\python36\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\admin\appdata\local\programs\python\python36\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
OSError: company-a-dat.txt not found.
In [52]: year,profit=loadtxt('company-a-data.txt')
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-52-b48e6119614d> in <module>
----> 1 year,profit=loadtxt('company-a-data.txt')
c:\users\admin\appdata\local\programs\python\python36\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\admin\appdata\local\programs\python\python36\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\admin\appdata\local\programs\python\python36\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
OSError: company-a-data.txt not found.
In [53]: year,profit=loadtxt('company-a-data.txt',unpack=true)
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
<ipython-input-53-de6020824536> in <module>
----> 1 year,profit=loadtxt('company-a-data.txt',unpack=true)
NameError: name 'true' is not defined
In [54]: year,profit=loadtxt('company-a-data.txt',unpack=True)
---------------------------------------------------------------------------
OSError Traceback (most recent call last)
<ipython-input-54-070812f8b62f> in <module>
----> 1 year,profit=loadtxt('company-a-data.txt',unpack=True)
c:\users\admin\appdata\local\programs\python\python36\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\admin\appdata\local\programs\python\python36\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\admin\appdata\local\programs\python\python36\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
OSError: company-a-data.txt not found.
In [55]:
Python-3.4.3 Other-Types-Of-Plots 02-03 min 10-20 sec
Answers:
The file company-a-data.txt should be in the directory you are running python. Or should know the path of where the file is present. If you are on windows use !type <filename>instead of cat. cat is a Linux command.
Login to add comment