> atm_chg.append(float( line.split()[-1] )) > > > np.asarray({atm_chg}) > > Execution still generates the errors: > > runfile('/home/comp/Apps/Python/Testing/ReadFile_2.py', > wdir='/home/comp/Apps/Python/Testing')
that means you have a blank line it's reading, the result of splitting an empty line is an empty list, which you can't index since it has no members. $ python Python 2.7.13 (default, Jan 12 2017, 17:59:37) [GCC 6.3.1 20161221 (Red Hat 6.3.1-1)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> ''.split() [] >>> ''.split()[-1] Traceback (most recent call last): File "<stdin>", line 1, in <module> IndexError: list index out of range >>> you're going to need to do a little input validation, always a good idea anyway. that is inside this loop: for line in f.readlines(): atm_chg.append(float( line.split()[-1] )) check there's something usable in line before you split-and-use it. _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor