Scott David Daniels wrote:
> True. The 2.4 document says that itertools.groupby() is equivalent to:
>
> class groupby(object):
> So you could always just use that code.
the right way to do that is to use the Python version as a fallback:
try:
from itertools import groupby
ex
Gábor Farkas wrote:
Scott David Daniels wrote:
If you have python 2.3 or 2.4, you have itertools.
for me it seems that 2.3 does not have itertools.groupby.
it has itertools, but not itertools.groupby.
True. The 2.4 document says that itertools.groupby() is equivalent to:
class groupby(object):
[EMAIL PROTECTED] wrote:
I would like to read this file as a record.
I can do this in perl by defining a record seperator;
is there an equivalent in python?
Depending on your exact use case, you may also get some mileage out of using the
csv module with a custom delimeter.
Py> from csv import re
Scott David Daniels wrote:
M.E.Farmer wrote:
I dont have itertools yet. That module looks like it rocks.
thanks for the pointers,
M.E.Farmer
If you have python 2.3 or 2.4, you have itertools.
for me it seems that 2.3 does not have itertools.groupby.
it has itertools, but not itertools.groupby.
act
Yea I should have mentioned I am running python 2.2.2.
Can it be ported to python 2.2.2?
Till they get python 2.4 all up and runningI'll wait a bit.
Thanks for the info,
M.E.Farmer
Scott David Daniels wrote:
> M.E.Farmer wrote:
> > I dont have itertools yet. That module looks like it rocks.
>
M.E.Farmer wrote:
I dont have itertools yet. That module looks like it rocks.
thanks for the pointers,
M.E.Farmer
If you have python 2.3 or 2.4, you have itertools.
--Scott David Daniels
[EMAIL PROTECTED]
--
http://mail.python.org/mailman/listinfo/python-list
Fredrik,
Thanks didn't realize that about reading a file on a for loop. Slick!
By the way the code I posted was an attempt at not building a
monolithic memory eating list like you did to return the values in your
second example.
Kinda thought it would be nice to read them as needed instead of all a
"M.E.Farmer" wrote:
> What about a generator and xreadlines for those really large files:
when you loop over a file object, Python uses a generator and a xreadlines-
style buffering system to read data as you go. (if you check the on-line help,
you'll notice that xreadlines itself is only provid
What about a generator and xreadlines for those really large files:
py>def recordbreaker(recordpath, seperator='#'):
... rec = open(recordpath ,'r')
... xrecord = rec.xreadlines()
... a =[]
... for line in xrecord:
... sep = line.find(seperator)
... if sep != -1:
...
[EMAIL PROTECTED] wrote:
Hi,
I know that i can do readline() from a file object.
However, how can I read till a specific seperator?
for exmple,
if my files are
name
profession
id
#
name2
profession3
id2
I would like to read this file as a record.
I can do this in perl by defining a record seperator
[EMAIL PROTECTED] wrote:
Hi,
I know that i can do readline() from a file object.
However, how can I read till a specific seperator?
for exmple,
if my files are
name
profession
id
#
name2
profession3
id2
I would like to read this file as a record.
I can do this in perl by defining a record seperator
[EMAIL PROTECTED] wrote:
> I know that i can do readline() from a file object.
> However, how can I read till a specific seperator?
>
> for exmple,
> if my files are
>
> name
> profession
> id
> #
> name2
> profession3
> id2
>
> I would like to read this file as a record.
> I can do this in perl b
Hi,
I know that i can do readline() from a file object.
However, how can I read till a specific seperator?
for exmple,
if my files are
name
profession
id
#
name2
profession3
id2
I would like to read this file as a record.
I can do this in perl by defining a record seperator;
is there an equivalen
13 matches
Mail list logo