My requirement is to generate csv file and append to a file in Amazon S3. I am able to do it using loop. My code is something like this.
import csv
import random
import simples3
from simples3 import S3Bucket
quantity=['12','5','13','2','7','6','4','9','15','21','33','62','54','18','26','1']
unitPrice=['1$','2$','3$','4$','5$','6$','7$','8$','9$','10$']
loop= [10]
myfile = open('testcsv.csv', 'ab')
s = S3Bucket('bucket_name',access_key='access_key',secret_key='secret_key')
for a in range(10):
writing=(random.choice(quantity),random.choice(unitPrice))
wr =csv.writer(myfile)
wr.writerow(writing)
loop.append(writing)
myfile.close()
print loop
pls = str(loop)
s.put("testconnection.csv",pls,mimetype="text/plain")
Now i want to write to the bucket file within my loop as i did for file in my local file system. I am not getting enough method in S3Bucket to append to a file and put is overwriting the content of file each time the loop executes. Please help me, i am newbie in Python and Amazon S3 world. Thanks in advance.