[SciPy-user] Newbie: Reading a slice of a file
v-nijs at kellogg.northwestern.edu
Mon Jan 15 12:28:50 CST 2007
I don't think you can do that directly with pylab.load. You could do
data = pylab.load(f,delimiter=',',skiprows=n-10)
Where n = the length of the file.
You could probably do something more flexible with the csv module. The
following will read all your data into an array (assumes all elements are
floats). You can add-in selection conditions as needed.
reader = csv.reader(file('yourfile.csv','r'))
data = numpy.array([i for i in reader])
data = data.astype('f')
On 1/15/07 11:51 AM, "Chiara Caronna" <chiaracaronna at hotmail.com> wrote:
> 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?
>> From: Darren Dale <dd55 at cornell.edu>
>> Reply-To: SciPy Users List <scipy-user at scipy.org>
>> To: SciPy Users List <scipy-user at scipy.org>
>> Subject: Re: [SciPy-user] Can SciPy compute ln(640320**3 + 744)/163**.5
>> to30 places?
>> Date: Mon, 15 Jan 2007 12:19:58 -0500
>> On Monday 15 January 2007 11:52, Dick Moores wrote:
>>> That's great! Thanks!
>>> Now, how about something such as (5/23)**(2/7)?
>>> print repr(n.exp(n.log(5/23)*2/7))
>>> gets ValueError: log domain error
>> integer division 5/23=0. The log of zero is either going to give you
>> or an error.
>> SciPy-user mailing list
>> SciPy-user at scipy.org
> Don't just search. Find. Check out the new MSN Search!
> SciPy-user mailing list
> SciPy-user at scipy.org
Vincent R. Nijs
Assistant Professor of Marketing
Kellogg School of Management, Northwestern University
2001 Sheridan Road, Evanston, IL 60208-2001
Phone: +1-847-491-4574 Fax: +1-847-491-2498
E-mail: v-nijs at kellogg.northwestern.edu
More information about the SciPy-user