11 April 2022

Abriendo archivo json desde S3 con Python y Boto3

Como cargar un archivo JSON desde AWS S3 con python (boto3)

Miguel Angel Acevedo
Miguel Angel Acevedo @faultydev
import boto3
import json

s3 = boto3.resource('s3')
bucket = "nombre-del-bucket"
file="nombre-del-archivo.json"

content_object = s3.Object('test', 'sample_json.txt')
file_content = content_object.get()['Body'].read().decode('utf-8')
json_content = json.loads(file_content)
print(json_content)

Categories

AWS Boto3 Python JSON S3