This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author skip.montanaro
Recipients gvanrossum, mishok13, ncoghlan, rhettinger, skip.montanaro
Date 2008-07-31.22:56:34
SpamBayes Score 2.3782413e-06
Marked as misclassified No
Message-id <1217544997.56.0.921461920116.issue3436@psf.upfronthosting.co.za>
In-reply-to
Content
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
History
Date User Action Args
2008-07-31 22:56:39skip.montanarosetrecipients: + skip.montanaro, gvanrossum, rhettinger, ncoghlan, mishok13
2008-07-31 22:56:37skip.montanarosetmessageid: <1217544997.56.0.921461920116.issue3436@psf.upfronthosting.co.za>
2008-07-31 22:56:36skip.montanarolinkissue3436 messages
2008-07-31 22:56:35skip.montanarocreate