On Monday 11 May 2009 14:36:17 Nils Wagner wrote: > On Mon, 11 May 2009 14:25:46 +0200 > > Francesc Alted <[email protected]> wrote: > > A Monday 11 May 2009, Nils Wagner escrigué: > >> Hi all, > >> > >> Please consider two strings > >> > >> >>> line_a > >> > >> '12345678abcdefgh12345678' > >> > >> >>> line_b > >> > >> '12345678 abcdefgh 12345678' > >> > >> >>> line_b.split() > >> > >> ['12345678', 'abcdefgh', '12345678'] > >> > >> Is it possible to split line_a such that the output > >> is > >> > >> ['12345678', 'abcdefgh', '12345678'] > > > > Mmh, your question is a bit too generic. > > Indeed. > I would like to split strings made of digits after eight > characters each. > > >>> line_a > > '111111.1222222.2333333.3' > > >>> line_b > > '111111.1 222222.2 333333.3' > > >>> line_b.split() > > ['111111.1', '222222.2', '333333.3'] > > How can I accomplish that ? would this suit you ? >>> np.asarray(line_b,dtype=[('hdr','|S8'),('mid','|S8'),('tail','|S8')]) array(('111111.1', '222222.2', '333333.3'), dtype=[('hdr', '|S8'), ('mid', '|S8'), ('tail', '|S8')])
hth, sebastien. -- ######################################### # Dr. Sebastien Binet # Laboratoire de l'Accelerateur Lineaire # Universite Paris-Sud XI # Batiment 200 # 91898 Orsay ######################################### _______________________________________________ Numpy-discussion mailing list [email protected] http://mail.scipy.org/mailman/listinfo/numpy-discussion
