Created
September 25, 2020 01:37
-
-
Save sengstacken/9c7021c6ddfcdc324b7bc3adfcf7c08d to your computer and use it in GitHub Desktop.
read data from s3
This file contains hidden or 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
#loop over all docs in the bucket | |
s3 = boto3.resource('s3') | |
bucket = s3.Bucket(bucket_name) | |
for obj in bucket.objects.all(): | |
if obj.key.split('/')[0].split('.')[-1] == 'txt': | |
obj_from_s3 = s3.Object(bucket, key) | |
file_content = obj_from_s3.get()['Body'].read().decode('utf-8') | |
json_content = json.loads(file_content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment