[Python-ideas] csv.DictReader could handle headers more intelligently.
alex23
wuwei23 at gmail.com
Fri Jan 25 02:49:53 CET 2013
On 25 Jan, 06:35, Serhiy Storchaka <storch... at gmail.com> wrote:
> On 23.01.13 03:51, alex23 wrote:
>
> > with open('malformed.csv','rb') as csvfile:
> > csvlines = list(l for l in csvfile if l.strip())
> > csvreader = DictReader(csvlines)
>
> csvreader = DictReader(l for l in csvfile if l.strip())
Uh, thanks, although I'm not sure what you think you're showing me
that I'm not already aware of. I spelled it out as two separate
expressions for clarity, I didn't realise we were playing code golf in
our examples.
More information about the Python-ideas
mailing list