本文介绍了检索 pandas 中read_csv推断的定界符的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用自动分隔符检测配置读取csv文件时( pd.read_csv(file_path,sep = None)),pandas会尝试推断定界符(或分隔符) )。
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 separator).
是否可以检索此推断的结果(最终用于 sep 的值)?
Is there a way to retrieve the result of this inference (the value that was finally used for sep)?
编辑
我正在寻找一种使用pandas对象的方法由 read_csv 返回。我使用的是0.20.2版的熊猫。
I am looking specifically for a method that uses the pandas object that is returned by read_csv. I use version 0.20.2 of pandas.
推荐答案我认为您无需导入就可以做到这一点。 csv :
reader = pd.read_csv(file_path, sep = None, iterator = True) inferred_sep = reader._engine.data.dialect.delimiter编辑:
忘记了 iterator = True 参数。
更多推荐
检索 pandas 中read
发布评论