Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with pysftp.Connection(host=host, username=userName, password=passWord) as sftpVal:
- #print(sftpVal.listdir()) #list directories in sftp home
- sftpVal.put(source_file_path,'incoming/'+fileName) #(localPath, destinationPath)
- with open('file_name.txt') as original_file, open('file_to_send.txt', 'w') as send_file: # Open the original and prepared files
- content = original_file.read()
- content = content.replace('rn', 'n') # Change the line endings
- content = content.encode('utf-8') # Encode in UTF-8
- send_file.write(content)
- # Do your file send here but with the prepared file instead.
- os.remove('file_to_send.txt') # Optional removal of temp file.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement