Message70532
Nick,
Working with Andrii's patch I'm trying to add a couple test cases to
make sure the methods you and I both demonstrated still work. Mine is
no problem, but I must be doing something wrong trying to use/adapt your
example. I freely admit I am not an itertools user, but I can't get
your example to work as written:
>>> r = csv.DictReader(open("foo.csv", "rb"))
>>> r.fieldnames
['f1', 'f2', 'f3']
>>> r.next()
{'f1': '1', 'f2': '2', 'f3': 'abc'}
>>> r = csv.DictReader(open("foo.csv", "rb"))
>>> first = next(r)
>>> first
{'f1': '1', 'f2': '2', 'f3': 'abc'}
>>> import itertools
>>> for x in itertools.chain(first, r):
... print x
...
f1
f2
f3
If I place first in a list it works:
>>> r = csv.DictReader(open("foo.csv", "rb"))
>>> first = next(r)
>>> for x in itertools.chain([first], r):
... print x
...
{'f1': '1', 'f2': '2', 'f3': 'abc'}
That makes intuitive sense to me. Is that what you intended?
S |
|
Date |
User |
Action |
Args |
2008-07-31 22:56:39 | skip.montanaro | set | recipients:
+ skip.montanaro, gvanrossum, rhettinger, ncoghlan, mishok13 |
2008-07-31 22:56:37 | skip.montanaro | set | messageid: <1217544997.56.0.921461920116.issue3436@psf.upfronthosting.co.za> |
2008-07-31 22:56:36 | skip.montanaro | link | issue3436 messages |
2008-07-31 22:56:35 | skip.montanaro | create | |
|