Finding Blank Columns in CSV

Chris Angelico rosuav at gmail.com
Mon Oct 5 10:34:17 EDT 2015


On Tue, Oct 6, 2015 at 1:06 AM, Tim Chase <python.list at tim.thechases.com> wrote:
> That way, if you determine by line 3 that your million-row CSV file
> has no blank columns, you can get away with not processing all
> million rows.

Sure, although that effectively means the entire job is moot. I kinda
assume that the OP knows that there are some blank columns (maybe lots
of them). The extra check is unnecessary unless it's actually
plausible that there'll be no blanks whatsoever.

Incidentally, you have an ordered_headers list which is the blank
columns in order; I think the OP was looking for a list of the
_non_blank columns. But that's a trivial difference, easy to tweak.

ChrisA



More information about the Python-list mailing list