Advertisement
Guest User

Untitled

a guest
Mar 4th, 2016
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. filename = 'mycsvfile' + dt.strftime("%Y%m%d") + '.csv'
  2. csvfilename = os.path.join(directory,filename)
  3. with open(csvfilename, 'w', newline='') as write_file: #using with closes the file automatically
  4.  
  5. write=csv.writer(write_file)
  6. write.writerow(['Date','MKWID','Conversion Type','Conversions','Revenue'])
  7. for r in csvlist:
  8. for num in range(0,4):
  9. arindx = 2 + num
  10. csvrow = [r[0],r[1],lablear[num],r[arindx],'0.00']
  11. if r[arindx] > 0 and r[1] != 'NA':
  12. write.writerow(csvrow)
  13. with pysftp.Connection('their_ftp_host.com', username='my_username', password='my_password') as sftp: #using with closes the file automatically
  14. sftp.cd('foldername1') # temporarily chdir to folder1
  15. sftp.cd('foldername2') # temporarily chdir to folder2
  16. sftp.put(csvfilename) # upload file to public/ on remote
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement