Created
July 18, 2021 09:51
-
-
Save blackrez/228470193f43b658522e9911a03a153d to your computer and use it in GitHub Desktop.
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') | |
resp = s3.select_object_content( | |
Bucket='carto-1000x', | |
Key='data/yellow_tripdata_2016–01.csv', | |
ExpressionType='SQL', | |
Expression="SELECT avg(cast(tip_amount as float)) , count(1) FROM s3object s", | |
InputSerialization = {'CSV': {"FileHeaderInfo": "Use", 'FieldDelimiter': ',','RecordDelimiter': '\n'}, 'CompressionType': 'NONE'}, | |
OutputSerialization = {'CSV': {}}, | |
) | |
for event in resp['Payload']: | |
if 'Records' in event: | |
records = event['Records']['Payload'].decode('utf-8') | |
print(records) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment