import os
import boto3
import json
from datetime import datetime,timedelta
s3 = boto3.client('s3', aws_access_key_id="<access_key>",
aws_secret_access_key="<secret_key>")
##my_bucket = s3.Bucket('grn-amazon')
filename_withdate=(datetime.now()-timedelta(days=6)).strftime ("%d%b%Y")
filename_withdate = filename_withdate+'_Consolidated.csv'
Source_filename = filename_withdate
dest_filename = filename_withdate
try:
## s3.download_file('grn-amazon',complt_filename,'01FEB2020_Consolidated.csv')
s3.download_file('grn-amazon',Source_filename,dest_filename)
print("Download Completed")
except botocore.exception.ClientErrors as e:
if e.response['Error']['Code'] == '404':
print('The Object does not exists!!')
else:
raise
Getting below error after running above code. Kindly help on this.. Passing Source and Destination file name as parameter in S3 attributes...
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Cloudtail\CT\SQL Scripts\python\GRN_S3_dwnld.py", line 17, in except botocore.exception.ClientErrors as e: NameError: name 'botocore' is not defined