Pandas CParseError,文件通过 FTP 下载

Pandas CParseError, file downloaded via FTP

我正在尝试使用 read_csv

在 Pandas 中读取 csv 文件(通过 FTP 下载)
df = pandas.read_csv("file.csv")

但我收到错误:

CParserError: Error tokenizing data. C error: EOF inside string starting at line 652

通过FTP下载文件的代码:

f = open(file_name, 'wb')
ftp.retrbinary("RETR " + file_name, f.write)

但是当我在浏览器上下载同一个文件并解析它时,它没有问题。请提出任何解决方案。

试试这个:

df = pandas.read_csv('ftp://...')  # puth there the real FTP URL

来自 docs:

filepath_or_buffer : str, pathlib.

Path, py._path.local.LocalPath or any object with a read() method (such as a file handle or StringIO)

The string could be a URL. Valid URL schemes include http, ftp, s3, and file.

For file URLs, a host is expected. For instance, a local file could be file ://localhost/path/to/table.csv