[SciPy-user] Convert a string list to array ?

Nathan Bell wnbell@gmail....
Tue Feb 26 14:09:02 CST 2008


On Tue, Feb 26, 2008 at 1:50 PM, Stef Mientki <s.mientki@ru.nl> wrote:
>  Is there a better (more elegant) way ?
>
>
>  And maybe the string list was even the wrong first step,
>  the datafile I'm reading looks like this:
>
>  254 48 57
>  58 52 53
>  58 51 54
>  254 32 32
>  32 32 32
>
>  So there might even be better ways to start ?

Try numpy.fromfile()

A = fromfile( 'myfile.txt', dtype=int, sep=' ')

This should be very fast and memory efficient.


-- 
Nathan Bell wnbell@gmail.com
http://graphics.cs.uiuc.edu/~wnbell/


More information about the SciPy-user mailing list