[Tutor] create numpy array from list of strings

bob gailer bgailer at gmail.com
Wed Jun 4 00:26:01 CEST 2008


washakie wrote:
> Hello, I have a list of strings:
> data = 
> [ '33386.47    2.22    -1.11   0.43'
> '33386.67     3.33     -1.23  0.54'
>  ...
> '46728.47    0.1    -1.87    -0.54'
> '46728.47    9.7    5.68    0.38'
> '46729.47    -0.17    -0.47    0.23']
>   
If the above is intended to be Python code, it has problems.

Rewrite it thusly?:

data = [ '33386.47    2.22    -1.11   0.43',
'33386.67     3.33     -1.23  0.54',
# ...
'46728.47    0.1    -1.87    -0.54',
'46728.47    9.7    5.68    0.38',
'46729.47    -0.17    -0.47    0.23']

Then let a numpy expert finish the task.

-- 
Bob Gailer
919-636-4239 Chapel Hill, NC



More information about the Tutor mailing list