pandas 使用Python 3从安全的FTP服务器读取数据 [英] Pandas read data from a secure FTP server in Python 3

查看:54
本文介绍了 pandas 使用Python 3从安全的FTP服务器读取数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个整洁的解决方案,以从Python 3中的安全FTP服务器读取数据(使用read_csv或read_sas)到Pandas Dataframe中.我能找到的所有示例很多行,而某些示例适用于Python 2.有没有一种巧妙的方法可以将您的用户名和密码以及ftp网址和文件夹一起插入类似于Pandas的read_csv方法中?

I am looking for a neat solution to read data (using either read_csv or read_sas) to a Pandas Dataframe from a secure FTP server in Python 3. All the examples I can find are many lines and some for Python 2. Isn't there a neat way to insert your username+password to Pandas read_csv-like method together with an ftp url and folder?

推荐答案

pandas.read_csv()接受类似文件的对象.Paramiko是处理SFTP的库,可以提供类似文件的对象.一旦您设置连接,它就很简单:

pandas.read_csv() accepts a file-like object. Paramiko is a library which handles SFTP and can provide file-like objects. Once you've set up the connection, it's simple as:

with sftp.open("file.csv") as f:
    pd.read_csv(f)

这篇关于 pandas 使用Python 3从安全的FTP服务器读取数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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