Introduction
Kinesis
- Data Firehose
- Create a Firehose client using boto3.
- Data Streams
- List the Data streams under the Firehose
- Delete the Data streams
- Create a Data stream
import boto3, pandas as pd
# Load Data
data_url = "https://assets.datacamp.com/production/repositories/5668/datasets/6bba555e0e42ae31d1d634256679db718cfb8d76/vehicles.csv"
records = pd.read_csv(data_url).sample(100)
# Create a firehose client
firehose = boto3.client('firehose',
aws_access_key_id="None",
aws_secret_access_key="None",
region_name='us-east-1',
endpoint_url="http://localhost:4573")
# Create a s3 client
s3 = boto3.client('s3',
aws_access_key_id="None",
aws_secret_access_key="None",
region_name='us-east-1',
endpoint_url="http://localhost:4572")
# Create s3 bucket
s3.create_bucket(Bucket='sd-vehicle-data')
# Create a Firehose delivery stream
res = firehose.create_delivery_stream(
DeliveryStreamName="gps-delivery-stream",
DeliveryStreamType="DirectPut",
# specify the S3 bucket, which is our destination
S3DestinationConfiguration = {
"BucketARN": "arn:aws:s3:::sd-vehicle-data",
"RoleARN": "arn:aws:iam::0000000:role/firehoseDeliveryRole"
})
# Print the stream ARN
print("Firehose Stream ARN is: {}".format(res['DeliveryStreamARN']))
for idx, row in records.iterrows():
payload = ' '.join(str(value) for value in row)
payload = payload + "\n"
print("Sending payload: {}".format(payload))
res = firehose.put_record(
DeliveryStreamName = 'gps-delivery-stream',
Record = {'Data': payload})
print("Record Id is: {}".format(res['RecordId']))
objects = s3.list_objects(Bucket='sd-vehicle-data')['Contents']
df = []
for obj in objects:
data_file = s3.get_object(Bucket='sd-vehicle-data', Key=obj['Key'])
dfs.append(pd.read_csv(data_file['Body'], delimiter = " ", names= ["record_id", "timestamp", "vin", "lon", "lat", "speed"]))
data = pd.concat(dfs)
print(data.groupby(['vin'])['speed'].max())
- Data Analytics
Introduction to Lambda & Step unctions
Creating an AWS free account and Launch the EC2 Instance
Creating and using the virtual environment
Working with Lambda
Performing data testing
Working with DBT Cloud
FKP Institite of AI
Copyright © 2024 FKP Institite of AI - All Rights Reserved.
We Simplify practical understanding of today's cutting edge Technologies.
We use cookies to analyze website traffic and optimize your website experience. By accepting our use of cookies, your data will be aggregated with all other user data.