Retrieve delimiter infered by read_csv in pandas

后端 未结 3 762
無奈伤痛
無奈伤痛 2021-02-13 04:18

When using the configuration for automatic separator detection to read csv files (pd.read_csv(file_path, sep=None)), pandas tries to infer the delimiter (or separat

3条回答
  •  清酒与你
    2021-02-13 04:55

    I think you can do this without having to import csv:

    reader = pd.read_csv(file_path, sep = None, iterator = True)
    inferred_sep = reader._engine.data.dialect.delimiter
    

    EDIT:

    Forgot the iterator = True argument.

提交回复
热议问题