I am trying to create an array with 2 columns and over 7000 rows (lots of data). The data I have is written as a text file and is formatted in two columns, each variable being separated by a space. My biggest problem is that NumPy can't seem to find the file.
1. import numpy as np 2. np.fromfile(stardata.txt) This returns:
NameError: name 'stardata' is not defined I have checked the directory and everything seems to be in order. The file is in the correct directory.
My next problem is seeing if this would make a good array. I am guessing I might have to use .reshape() to make it look the way I want it to be. After that, I will be using the data to make a (Hertzsprung-Russell) diagram.
The full error message is here:
C:\Users\Petar\AppData\Local\Enthought\Canopy\System\lib\site-packages\IPython\utils\py3compat.pyc in execfile(fname, glob, loc) 174 else: 175 filename = fname --> 176 exec compile(scripttext, filename, 'exec') in glob, loc 177 else: 178 def execfile(fname, *where): C:\Users\Petar\Desktop\test.py in <module>() 1 import numpy as np ----> 2 np.fromfile(stardata.txt) NameError: name 'stardata' is not defined
np.fromfileto load a text file.np.genfromtxtis much improved.