[New-bugs-announce] [issue43625] CSV has_headers heuristic could be improved

ejacq report at bugs.python.org
Thu Mar 25 14:18:35 EDT 2021


New submission from ejacq <0python3 at jesuislibre.net>:

Here is an sample of CSV input:

"time","forces"
0,0
0.5,0.9

when calling has_header() from csv.py on this sample, it returns false.
Why? because 0 and 0.5 don't belong to the same type and thus the column is discarded by the heuristic.

I think the heuristic will better work if rather than just comparing number types, it would also consider casting the values in this order int -> float -> complex. If the values are similar then consider this upgraded type as the type of the column.

In the end, this file would be considered float columns with headers.

----------
components: Library (Lib)
messages: 389515
nosy: ejacq
priority: normal
severity: normal
status: open
title: CSV has_headers heuristic could be improved
versions: Python 3.7

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


More information about the New-bugs-announce mailing list