Advertisement
Guest User

Untitled

a guest
Jan 23rd, 2016
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. with pysftp.Connection(host=host, username=userName, password=passWord) as sftpVal:
  2. #print(sftpVal.listdir()) #list directories in sftp home
  3. sftpVal.put(source_file_path,'incoming/'+fileName) #(localPath, destinationPath)
  4.  
  5. with open('file_name.txt') as original_file, open('file_to_send.txt', 'w') as send_file: # Open the original and prepared files
  6. content = original_file.read()
  7. content = content.replace('rn', 'n') # Change the line endings
  8. content = content.encode('utf-8') # Encode in UTF-8
  9. send_file.write(content)
  10.  
  11. # Do your file send here but with the prepared file instead.
  12.  
  13. os.remove('file_to_send.txt') # Optional removal of temp file.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement