I am trying to create an array of integers from a list of strings to do some calculations, but all I can get is an array of strings or an error.
Does numpy have any functions to do this? any help at all would be much appreciated.
infile:
23 CL 006 2004 DBA8ORPU 41 8Y 0 S0111P 2
53 CL 006 2004 LBA8PUYE 32 10Y 0 S0111P 2
39 CL 006 2004 A8LGPUYE 10 TY 2 S0111P 2
from numpy import *
infile = open("C:\Python25\Drew\idage.txt", 'r')
rcw = infile.readlines()
for record in rcw:
bird = record.strip().split()
a = array('f',[bird[0],bird[2],bird[3],bird[5],bird[9],bird[7]])
print a
Traceback (most recent call last):
File "C:\Python25\Drew\agecal.py", line 23, in <module>
a = array('f',[bird[0],bird[2],bird[3],bird[5],bird[9],bird[7]])
TypeError: data type not understood
without the 'f' (which I wanted to indicate floating point) I get the following array of strings: