Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
S3 partition extraction in Python
import re
regex = r"(year|month|day|hour)=(\d+)"
test_str = "s3://bucket/datalake/year=2019/month=12/day=02/hour=06"
matches = re.finditer(regex, test_str)
partition = { int( for match in matches}
# {'year': 2019, 'month': 12, 'day': 2, 'hour': 6}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment