Created
March 11, 2020 16:05
-
-
Save prashanthmadi/1e6ff6e46ff714affba51aa92d7d1c2a to your computer and use it in GitHub Desktop.
Databricks Recursive listing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import boto3 | |
s3 = boto3.client('s3') | |
bucket = 'databricks-datasets-virginia' | |
prefix = 'airlines/' | |
objects = s3.list_objects_v2(Bucket=bucket, Prefix=prefix, Delimiter = "/") | |
files = [] | |
for obj in objects['Contents']: | |
files.append(obj) | |
while objects['IsTruncated']: | |
continuation_key = objects['NextContinuationToken'] | |
objects = s3.list_objects_v2(Bucket=bucket, Prefix=prefix, Delimiter="/", ContinuationToken=continuation_key) | |
for obj in objects['Contents']: | |
files.append(obj) | |
for file in files: | |
print(file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment