[Numpy-discussion] String manipulation

Nils Wagner nwagner@iam.uni-stuttgart...
Mon Jul 20 05:34:20 CDT 2009

On Mon, 11 May 2009 10:48:14 -0400
  Alan G Isaac <aisaac@american.edu> wrote:
> On 5/11/2009 8:36 AM Nils Wagner apparently wrote:
>> I would like to split strings made of digits after eight 
>> characters each.
> [l[i*8:(i+1)*8] for i in range(len(l)/8)]
> Alan Isaac
> _______________________________________________
> Numpy-discussion mailing list
> Numpy-discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion

  1.000000E+00 0.000000E+00 1.000000E+00 1.000000E+00 
1.000000E+00 1.000000E+00
1.250000E+00 1.250000E+00
ifile = open('mydata','r')
lines = ifile.readlines()
for line in lines:
       print line.split()

How can I split the second line in such a way that I get

['-1.000000E+00', '-1.000000E+00', '-1.000000E+00', 
'-1.000000E+00', '1.250000E+00', '1.250000E+00']

instead of

'1.250000E+00', '1.250000E+00']

Thanks in advance


More information about the NumPy-Discussion mailing list