I am trying to download a CSV file (in-memory) from SFTP using Paramiko and import it into a pandas dataframe.
transport = paramiko.Transport((server, 22))
transport.connect(username=username, password=password)
sftp = paramiko.SFTPClient.from_transport(transport)
with open(file_name, 'wb') as fl:
sftp.getfo(file_name, fl, callback=printTotals)
df = pd.read_csv(fl, sep=' ')
The code below fails, telling me:
OSError: File is not open for reading
I assume that I need some kind of buffer or file like object for fl
instead, since open needs a file. I am relatively new to all of this, so I would be happy it if someone could help.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…