Re: list comprehension help

2007-03-18 Thread Shane Geiger
Since you are dealing with that much information perhaps pytables would be useful to you.http://pytables.sourceforge.net [EMAIL PROTECTED] wrote: Hi I need to process a really huge text file (4GB) and this is what i need to do. It takes for ever to complete this. I read some where that "l

Re: list comprehension help

2007-03-18 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: ... > > > files (you see "huge" is really relative ;-)) on 2-4GB RAM boxes and > > > setting a big buffer (1GB or more) reduces the wall time by 30 to 50% > > > compared to the default value. BerkeleyDB should have a buffering > > Out of curiosity, wh

Re: list comprehension help

2007-03-18 Thread [EMAIL PROTECTED]
On 3/18/07, Alex Martelli <[EMAIL PROTECTED]> wrote: > George Sakkis <[EMAIL PROTECTED]> wrote: > > On Mar 18, 12:11 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > > > I need to process a really huge text file (4GB) and this is what i > > > need to do. It takes for ever to complete this. I re

Re: list comprehension help

2007-03-18 Thread Alex Martelli
George Sakkis <[EMAIL PROTECTED]> wrote: > On Mar 18, 12:11 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > > > Hi > > I need to process a really huge text file (4GB) and this is what i > > need to do. It takes for ever to complete this. I read some where that > > "list comprehension" can fa

Re: list comprehension help

2007-03-18 Thread [EMAIL PROTECTED]
On 18 Mar 2007 19:01:27 -0700, George Sakkis <[EMAIL PROTECTED]> wrote: > On Mar 18, 12:11 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > > I need to process a really huge text file (4GB) and this is what i > > need to do. It takes for ever to complete this. I read some where that > > "list c

Re: list comprehension help

2007-03-18 Thread George Sakkis
On Mar 18, 12:11 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi > I need to process a really huge text file (4GB) and this is what i > need to do. It takes for ever to complete this. I read some where that > "list comprehension" can fast up things. Can you point out how to do > it in this

Re: list comprehension help

2007-03-18 Thread Alex Martelli
f<[EMAIL PROTECTED]> wrote: > I wonder whether the following be more efficient if DB was a > dictionnary: > > Splits = (line.split(' ') for line in open('file.text', 'r')) > DB = dict([(S[0], S[-1]) for S in Splits]) You'd still be doing much more splitting work (and behind-the-scene allocation

Re: list comprehension help

2007-03-18 Thread Alex Martelli
George Sakkis <[EMAIL PROTECTED]> wrote: ... > > Unless each line is huge, how exactly you split it to get the first and > > last blank-separated word is not going to matter much. > > > > Still, you should at least avoid repeating the splitting twice, that's > > pretty obviously sheer waste: so,

Re: list comprehension help

2007-03-18 Thread George Sakkis
On Mar 18, 1:40 pm, [EMAIL PROTECTED] (Alex Martelli) wrote: > [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > On 3/18/07, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > > > In <[EMAIL PROTECTED]>, Daniel Nogradi > > > wrote: > > > > >> f = open('file.txt','r') > > > >> for line in f: > > >

Re: list comprehension help

2007-03-18 Thread cptnwillard
I wonder whether the following be more efficient if DB was a dictionnary: Splits = (line.split(' ') for line in open('file.text', 'r')) DB = dict([(S[0], S[-1]) for S in Splits]) -- http://mail.python.org/mailman/listinfo/python-list

Re: list comprehension help

2007-03-18 Thread Alex Martelli
[EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > On 3/18/07, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > > In <[EMAIL PROTECTED]>, Daniel Nogradi > > wrote: > > > > >> f = open('file.txt','r') > > >> for line in f: > > >> db[line.split(' ')[0]] = line.split(' ')[-1] > > >>

Re: list comprehension help

2007-03-18 Thread Daniel Nogradi
> > > I need to process a really huge text file (4GB) and this is what i > > > "list comprehension" can fast up things. Can you point out how to do > > > f = open('file.txt','r') > > > for line in f: > > > db[line.split(' ')[0]] = line.split(' ')[-1] > > > db.sync() > > > > What is

Re: list comprehension help

2007-03-18 Thread [EMAIL PROTECTED]
On 3/18/07, Marc 'BlackJack' Rintsch <[EMAIL PROTECTED]> wrote: > In <[EMAIL PROTECTED]>, Daniel Nogradi > wrote: > > >> f = open('file.txt','r') > >> for line in f: > >> db[line.split(' ')[0]] = line.split(' ')[-1] > >> db.sync() > > > > What is db here? Looks like a dictionary but

Re: list comprehension help

2007-03-18 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Daniel Nogradi wrote: >> f = open('file.txt','r') >> for line in f: >> db[line.split(' ')[0]] = line.split(' ')[-1] >> db.sync() > > What is db here? Looks like a dictionary but that doesn't have a sync method. Shelves (`shelve` module) have this API. And

Re: list comprehension help

2007-03-18 Thread [EMAIL PROTECTED]
On 3/18/07, Daniel Nogradi <[EMAIL PROTECTED]> wrote: > > I need to process a really huge text file (4GB) and this is what i > > "list comprehension" can fast up things. Can you point out how to do > > f = open('file.txt','r') > > for line in f: > > db[line.split(' ')[0]] = line.split(' ')[

Re: list comprehension help

2007-03-18 Thread Daniel Nogradi
> I need to process a really huge text file (4GB) and this is what i > need to do. It takes for ever to complete this. I read some where that > "list comprehension" can fast up things. Can you point out how to do > it in this case? > thanks a lot! > > > f = open('file.txt','r') > for line in f: >

Re: list comprehension help

2007-03-18 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, [EMAIL PROTECTED] wrote: > I need to process a really huge text file (4GB) and this is what i > need to do. It takes for ever to complete this. I read some where that > "list comprehension" can fast up things. Can you point out how to do > it in this case? No way I can see

list comprehension help

2007-03-18 Thread [EMAIL PROTECTED]
Hi I need to process a really huge text file (4GB) and this is what i need to do. It takes for ever to complete this. I read some where that "list comprehension" can fast up things. Can you point out how to do it in this case? thanks a lot! f = open('file.txt','r') for line in f: db[line.