[issue43625] CSV has_headers heuristic could be improved

Andrei Kulakov report at bugs.python.org
Mon Jun 28 23:10:20 EDT 2021


Andrei Kulakov <andrei.avk at gmail.com> added the comment:

Skip: If I understand right, in the patch the last two types -- float and int, will never have an effect because if float(x) and int(x) succeed, so will complex(x), and conversely, if complex(x) fails, float and int will also fail.

So the effect of the patch will be to tolerate any mix of numeric columns when the headers are textual. Which sounds fine to me, just want to confirm that sounds good to you, because the unit test in the patch is a much narrower case.

I think the test should then be something like:

a    b    c
1   1.1   5+0j
1.2 3+0j  4 

and the code should be updated to just do `complex(x)` and remove float() and int() attempts.

Another, more strict option, - would be to special case `0` to match int, float, and complex.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue43625>
_______________________________________


More information about the Python-bugs-list mailing list