Forums

Full Version: How to read a csv file from SFTP using python?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Using python script component.
Paste below script in meta information script section.
Provide connection credentials.

import pandas as pd
import paramiko
def myconnect():
   ssh = paramiko.SSHClient()
   ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
   ssh.connect('localhost',port=22,username='user',password='123456')
   #print("connected suceessfully to SFTP Server")
   sftp_client = ssh.open_sftp()
   sftp_client.chdir('/home/user/folder_name')
   df= pd.read_csv(sftp_client.open('/home/user/folder_name/file_name.csv'))
   sftp_client.close()
   ssh.close()
   return df