检索 pandas 中read_csv推断的定界符 [英] Retrieve delimiter infered by read_csv in pandas

查看:80
本文介绍了检索 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_csv推断的定界符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆