Skip to main content

has_header

Function has_header 

Source
pub fn has_header(sample: &str) -> Option<bool>
Expand description

Port of csv.Sniffer.has_header: if a column is one consistent type in every row except the first, the first row is a label. Each column casts one vote.

The typing is CPython’s current one — a single complex attempt, falling back to the string’s length. The historical for thisType in [int, float, complex] loop is NOT equivalent: it makes a column mixing 10 and 9.5 read as inconsistent (int then float), so price,note / 10,aa / 9.5,bbb loses its header.

None is CPython’s csv.Error escaping from the re-sniff, which upstream handles the same way as a failed sniff.