[Tutor] create numpy array from list of strings

washakie washakie at gmail.com
Wed Jun 4 01:03:52 CEST 2008


Thanks,

I'm not really trying to create a function. I actually thought this would be
as simple as the 'load' command to get the data in from a file. But I just
couldn't find the documentation online to do it once i have the data already
'inside' of python as a list. So, my options are:

1) write the data block out to a temporary file and read it in using 'load'
- which is really simple (see: http://www.scipy.org/Cookbook/InputOutput)

2) I've done the following, but I doubt it is the most efficient method:
    
tempDATA=[]
for i in data[stind:-1]:  #this is the data block from the file
        tempDATA.append([float(j) for j in i.split()])

outdata=array(tempDATA).transpose()

Is there a better way?


-- 
View this message in context: http://www.nabble.com/create-numpy-array-from-list-of-strings-tp17634509p17635787.html
Sent from the Python - tutor mailing list archive at Nabble.com.



More information about the Tutor mailing list