1 Answer
- Newest
- Most votes
- Most comments
0
Hi,
Athena automatically creates metadata files when it moves files using the start_query_execution command. In order to delete the .csv.metadata files, you can use the following logic below. Make sure to use item.key to get the name of the object. The try statement will skip over the s3.ObjectSummary object that is giving this error.
session = boto3.session.Session()
s3 = session.resource('s3')
my_bucket = s3.Bucket(<bucketname>)
for item in my_bucket.objects.filter(Prefix=<subbucketpath>):
try:
if item.key.endswith('.csv.metadata'):
item.delete()
except Exception as e:
print("The following error occured: {}".format(e))
Reference: https://docs.aws.amazon.com/athena/latest/ug/querying.html
answered 8 months ago
Relevant content
- asked 9 months ago
- asked 5 months ago
- asked a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 3 years ago
- AWS OFFICIALUpdated 7 months ago