【发布时间】:2018-03-09 02:08:48
【问题描述】:
我有 10 个 10mb 到 8gb 的文件数据集,我正在尝试读取大小为 8gb 的数据集 txt,但由于“¦”(断管)而无法读取...几乎所有大小超过 200mb 的数据集都有同样的问题,最小的文件有“正常”管道(|)。
代码是:
p = 0.001 # % of lines df = pd.read_csv("protectedSearch_GPRS.txt", sep='¦', skiprows= lambda i: i>0 and random.random() > p) ParserWarning: Falling back to the 'python' engine because the separator encoded in utf-8 is > 1 char long, and the 'c' engine does not support such separators; you can avoid this warning by specifying engine='python'. after removing the cwd from sys.path.
那么它到底是什么?它是一个错误吗?如何处理这个问题?我试图解决这个问题有 2 天,我真的不知道该怎么做。
非常感谢您,对于任何语言错误,我们深表歉意。
【问题讨论】:
-
你用的是linux机器吗?
-
嘿老鹰,我使用的是 Windows 10
-
很糟糕,我有一个快速的方法来更改分隔符,但它是 *nix 特定的
-
这是 unicode “断条”字符,它不在 ascii 字符集中。 Pandas 默认使用基于 C 的 csv 解析器,但它只有单字节,无法处理该字符。警告告诉你 pandas 正在退回到较慢的 python 实现。这大多是无害的。您可以按照警告中的说明来避免警告。
-
在powershell中试试这个,然后用正常的
'|'分隔符加载它:(get-content "path:\\protectedSearch_GPRS.txt") -replace '¦','|' | set-content "path:\\protectedSearch_GPRS.txt只需用实际路径替换path
标签: python pandas broken-pipe