Re: Getting values out of a CSV

2007-07-15 Thread Alex Popescu
On Jul 15, 3:00 pm, Steve Holden <[EMAIL PROTECTED]> wrote: > Alex Popescu wrote: > > On Jul 14, 5:55 am, "Gabriel Genellina" <[EMAIL PROTECTED]> > > wrote: > >> So, as always, one should measure in each specific case if optimization is > >> > >> worth the pain [...]. > > > I hope I am somehow m

Re: Getting values out of a CSV

2007-07-15 Thread Steve Holden
Alex Popescu wrote: > On Jul 14, 5:55 am, "Gabriel Genellina" <[EMAIL PROTECTED]> > wrote: >> So, as always, one should measure in each specific case if optimization is >> worth the pain [...]. >> > > I hope I am somehow misreading the above sentence :-). IMO synonim > language contructs > shoul

Re: Getting values out of a CSV

2007-07-14 Thread Alex Popescu
On Jul 14, 5:55 am, "Gabriel Genellina" <[EMAIL PROTECTED]> wrote: > > So, as always, one should measure in each specific case if optimization is > worth the pain [...]. > I hope I am somehow misreading the above sentence :-). IMO synonim language contructs should result in the same performance

Re: Getting values out of a CSV

2007-07-13 Thread Gabriel Genellina
En Fri, 13 Jul 2007 09:05:29 -0300, Daniel <[EMAIL PROTECTED]> escribió: >>> > Note that every time you see [x for x in ...] with no condition, you >>> can >>> > write list(...) instead - more clear, and faster. >>> > >>> > data = list(csv.reader(open('some.csv', 'rb'))) >>> >>> Faster? No. List C

Re: Getting values out of a CSV

2007-07-13 Thread Kelvie Wong
Hrm. Repeating the test several more times, it seems that the value fluctuates, sometimes one's faster than the other, and sometimes they're the same. Perhaps the minute difference between the two is statistically insignificant? Or perhaps the mechanism underlying both (i.e. the implementation)

Re: Getting values out of a CSV

2007-07-13 Thread Daniel
On Fri, 13 Jul 2007 16:18:38 +0300, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: >> $ python -m timeit -c 'import csv; data = >> list(csv.reader(open("some.csv", >> "rb")))' >> 1 loops, best of 3: 44 usec per loop >> $ python -m timeit -c 'import csv; data = [row for row in >> csv.re

Re: Getting values out of a CSV

2007-07-13 Thread Marc 'BlackJack' Rintsch
On Fri, 13 Jul 2007 15:05:29 +0300, Daniel wrote: >>> > Note that every time you see [x for x in ...] with no condition, you >>> can >>> > write list(...) instead - more clear, and faster. >>> > >>> > data = list(csv.reader(open('some.csv', 'rb'))) >>> >>> Faster? No. List Comprehensions are fas

Re: Getting values out of a CSV

2007-07-13 Thread Daniel
>> > Note that every time you see [x for x in ...] with no condition, you >> can >> > write list(...) instead - more clear, and faster. >> > >> > data = list(csv.reader(open('some.csv', 'rb'))) >> >> Faster? No. List Comprehensions are faster. > > [EMAIL PROTECTED] pdfps $ python -m timeit -c 'da

Re: Getting values out of a CSV

2007-07-13 Thread Michael Hoffman
Daniel wrote: > On Fri, 13 Jul 2007 08:51:25 +0300, Gabriel Genellina > <[EMAIL PROTECTED]> wrote: > >> Note that every time you see [x for x in ...] with no condition, you >> can write list(...) instead - more clear, and faster. > > Faster? No. List Comprehensions are faster. Why do you think

Re: Getting values out of a CSV

2007-07-13 Thread Kelvie Wong
On 7/12/07, Daniel <[EMAIL PROTECTED]> wrote: > On Fri, 13 Jul 2007 08:51:25 +0300, Gabriel Genellina > <[EMAIL PROTECTED]> wrote: > >> data = [row for row in csv.reader(open('some.csv', 'rb')) > > > > Note that every time you see [x for x in ...] with no condition, you can > > write list(...) inst

Re: Getting values out of a CSV

2007-07-12 Thread Daniel
On Fri, 13 Jul 2007 08:51:25 +0300, Gabriel Genellina <[EMAIL PROTECTED]> wrote: >> data = [row for row in csv.reader(open('some.csv', 'rb')) > > Note that every time you see [x for x in ...] with no condition, you can > write list(...) instead - more clear, and faster. > > data = list(csv.read

Re: Getting values out of a CSV

2007-07-12 Thread Gabriel Genellina
En Fri, 13 Jul 2007 02:10:17 -0300, Daniel <[EMAIL PROTECTED]> escribió: > data = [row for row in csv.reader(open('some.csv', 'rb')) Note that every time you see [x for x in ...] with no condition, you can write list(...) instead - more clear, and faster. data = list(csv.reader(open('some.csv'

Re: Getting values out of a CSV

2007-07-12 Thread Daniel
On Fri, 13 Jul 2007 05:59:53 +0300, <[EMAIL PROTECTED]> wrote: > > How do I access the value in the second row in the first position of a > CSV? Or the 3rd row, in the fifth position? > > a,b,c,d,e,f,g,h,i > j,k,l,m,n,o,p,q,r > r,s,t,v,w,x,y,z > > I'd want to get at "j" and "w". I know I can do >