Skip to content

Header Detection Error #44

@ben-bitdotio

Description

@ben-bitdotio

CleverCSV's Sniffer assumes the following .csv file does not have a header. More specifically, it recognizes "1" (an inferred int) and "1.2" (an inferred float) as incompatible types. As the third column has "incompatible" types, Detector.has_header() will return False.

col1,col2,col3
hello,"hello world", 1.2
world,"hello world", 1.2
test,"hello world 您", 1

Relevant code:

def clevercsv_guess_if_headers_exist(input: IO) -> bool:
    input_data = input
    if not isinstance(input, io.TextIOBase):
        input_data = io.StringIO(input.read(SAMPLE_LENGTH).decode())
    stream_pos = input_data.tell()
    sniffer = clevercsv.Sniffer()
    input_data.seek(0)
    has_header = sniffer.has_header(input_data.read(SAMPLE_LENGTH))
    input_data.seek(stream_pos)
    return has_header

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions