Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
#!/usr/bin/env python3
import re
import boto3
from collections import Counter
from humanize import naturalsize
s3_client = boto3.client('s3')
paginator = s3_client.get_paginator('list_objects')
sizes = Counter()
for page in paginator.paginate(Bucket='sga-tiles'):
for o in page['Contents']:
if'ms_abinger_c', o['Key']):
sizes['ms_abinger_c'] += o['Size']
elif'ms_shelley_e', o['Key']):
sizes['ms_shelley_e'] += o['Size']
sizes['other'] += o['Size']
for name, size in sizes.most_common():
print(name, naturalsize(size))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.