AWSPlay (Python CSV Parsing)

#csvCreds.py
import csv

def getSecret(file=”C:\Users\cstgeorge\Downloads\credentials.csv”):
with open(file, “rb”) as ofile:
reader = csv.DictReader(ofile, delimiter=’,’)
for row in reader:
return row[‘Secret Access Key’]

def getID(file=”C:\Users\cstgeorge\Downloads\credentials.csv”):
with open(file, “rb”) as ofile:
reader = csv.DictReader(ofile, delimiter=’,’)
for row in reader:
return row[‘Access Key Id’]

#awsPlay.py
import csvCreds
import boto
from boto.s3.key import Key

if __name__ == “__main__”:
conn = boto.connect_s3(csvCreds.getID(), csvCreds.getSecret())
bucket = conn.get_bucket(‘mikroburepo’)
#bucket = conn.delete_bucket(‘mikroscburepo’)
bucket.list()
key = Key(bucket)
key.key = ‘FirstFolder/myface’
#key.set_contents_from_filename(‘face.jpg’)
key.get_contents_to_filename(‘AWSface.jpg’)

Leave a Reply

Your email address will not be published. Required fields are marked *