-
-
Notifications
You must be signed in to change notification settings - Fork 34.7k
False negative from csv.Sniffer.has_header with only strings #102140
Copy link
Copy link
Open
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Metadata
Metadata
Assignees
Labels
3.13bugs and security fixesbugs and security fixes3.14bugs and security fixesbugs and security fixes3.15pre-release feature fixes, bugs and security fixespre-release feature fixes, bugs and security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
Fields
Give feedbackNo fields configured for issues without a type.
Projects
StatusShow more project fields
In Progress
Bug report
On the following CSV content, the
csv.Sniffer.has_headermethod returnsFalsealthough it clearly has a header.I believe this is due to the following lines in the
has_headermethod.When all columns are strings both
thisTypeandcolumnTypes[col]are integers denoting their length. Since they are of different lengths all the column are removed andcolumnTypesends up being an empty dictionary which leads to the false negative down the line.I believe there needs to be a special case introduced to avoid this when comparing integers rather than types.
Your environment
Linux helios 5.17.5-76051705-generic #202204271406~1653440576~20.04~6277a18-Ubuntu SMP PREEMPT Thu Ma x86_64 x86_64 x86_64 GNU/LinuxLinked PRs