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