Advertisement
Guest User

Waybz

a guest
Aug 22nd, 2018
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.00 KB | None | 0 0
  1. import pysftp
  2. import pandas as pd
  3.  
  4. host = r'sftp.conexussolutionsinc.com'
  5. username = r'01ASkaiser'
  6. password = r'K@!ser3007$bdu'
  7.  
  8. cnopts = pysftp.CnOpts()
  9. cnopts.hostkeys = None    # disable host key checking.
  10.  
  11. df_list = []
  12.  
  13. with pysftp.Connection(host, username=username, password=password, cnopts=cnopts) as sftp:
  14.     sftp.chdir(r'/From_Aclaris')
  15.     #print sftp.pwd
  16.    
  17.    
  18.     # Filedir = list of every file in the /From_Aclaris/ folder; consider replacing manually so you can
  19.     # add on the date at end
  20.    
  21.     filedir = sftp.listdir()
  22.     filedir = []
  23.    
  24.     filedir.append('')
  25.     filedir.append('')
  26.     filedir.append('')
  27.  
  28.     #print filedir
  29.    
  30.     localdir = r"C:/Users/GerardoZampaglione/Desktop/temp/"
  31.    
  32.     for filename in filedir:
  33.         l_path = localdir + filename
  34.         sftp.get(remotepath = filename, localpath=l_path, preserve_mtime=True)
  35.        
  36.         #l_path is the item that gets you to each filename
  37.         df_list.append(pd.read_table(l_path))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement