[SciPy-user] Newbie: Reading a slice of a file

Chiara Caronna chiaracaronna at hotmail.com
Wed Jan 17 02:34:39 CST 2007


Thank you, but the problem is that in the file from time to time there are 
non numerical values, so I need to skip those rows...

>From: Markus Rosenstihl <markusro at element.fkp.physik.tu-darmstadt.de>
>Reply-To: SciPy Users List <scipy-user at scipy.org>
>To: SciPy Users List <scipy-user at scipy.org>
>Subject: Re: [SciPy-user] Newbie: Reading a slice of a file
>Date: Wed, 17 Jan 2007 00:21:02 +0100
>
>Am 15.01.2007 um 18:51 schrieb Chiara Caronna:
>
>>I need to read just some rows of a file... do you know how to do it?
>>I found out that with pylab.load I can skip some rows from the top, but I
>>don't know how to skip from the bottom... maybe there is an other 
>>function?
>>Thanks
>>Chiara
>
>Hi
>
>You can use scipy.io.read_array:
>
>
>In [313]: b
>Out[313]:
>array([[0, 0, 0],
>        [1, 0, 0],
>        [2, 0, 0],
>        [3, 0, 0],
>        [4, 0, 0],
>        [5, 0, 0],
>        [6, 0, 0],
>        [7, 0, 0],
>        [8, 0, 0],
>        [9, 0, 0]])
>
>In [314]: scipy.io.write_array('testarray',b)
>
>In [315]: scipy.io.read_array('testarray',lines=(1,(4,7)))
>Out[315]:
>array([[ 1.,  0.,  0.],
>        [ 4.,  0.,  0.],
>        [ 5.,  0.,  0.],
>        [ 6.,  0.,  0.]])
>
>In [316]:
>
>HTH,
>
>Markus


><< PGP.sig >>




>_______________________________________________
>SciPy-user mailing list
>SciPy-user at scipy.org
>http://projects.scipy.org/mailman/listinfo/scipy-user

_________________________________________________________________
Don't just search. Find. Check out the new MSN Search! 
http://search.msn.com/



More information about the SciPy-user mailing list