br
is the name of a list of strings that goes like this:
['14 0.000000 -- (long term 0.000000)\n',
'19 0.000000 -- (long term 0.000000)\n',
'22 0.000000 -- (long term 0.000000)\n',
...
I am interested in the first two columns, which I would like to convert to a numpy array. So far, I've come up with the following solution:
x = N.array ([0., 0.])
for i in br:
x = N.vstack ( (x, N.array (map (float, i.split ()[:2]))) )
This results into having a 2-D array:
array([[ 0., 0.],
[ 14., 0.],
[ 19., 0.],
[ 22., 0.],
...
However, since br
is rather big (~10^5 entries), this procedure takes some time.
I was wondering, is there a way to accomplish the same result, but in less time?