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 logging | |
import pandas as pd | |
import awswrangler as wr | |
from src.timeseries_data_generator import TimeseriesGenerator | |
def upload_timeseries_data_to_s3(df: pd.DataFrame) -> None: | |
result = wr.s3.to_parquet( | |
df, | |
path=f"s3://data-lake-bronze/timeseries/", |
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 numpy as np | |
import pandas as pd | |
class TimeseriesGenerator: | |
def __init__( | |
self, | |
start_date: str, | |
end_date: str, | |
frequency: str = "H", |
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 | |
sns = boto3.client("sns", region_name="eu-central-1") | |
# CREATE TOPIC | |
topic_name = "ge_timeseries_data_test" | |
create_response = sns.create_topic(Name=topic_name) | |
topic_arn = create_response.get("TopicArn") | |
# CREATE SUBSCRIPTIONS |
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 | |
import pandas as pd | |
s3_bucket = "awebsite" | |
html_file = "sales_report.html" | |
df = pd.DataFrame([{'year': 2021, 'month': 8, 'order_status': 'unavailable', 'order_count': 48}, | |
{'year': 2021, 'month': 8, 'order_status': 'delivered', 'order_count': 7069}, | |
{'year': 2021, 'month': 8, 'order_status': 'invoiced', 'order_count': 15}, | |
{'year': 2021, 'month': 8, 'order_status': 'shipped', 'order_count': 74}, |
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 | |
import pandas as pd | |
s3_bucket = "annageller" | |
html_file = "sales_report.html" | |
df = pd.DataFrame([{'year': 2021, 'month': 8, 'order_status': 'unavailable', 'order_count': 48}, | |
{'year': 2021, 'month': 8, 'order_status': 'delivered', 'order_count': 7069}, | |
{'year': 2021, 'month': 8, 'order_status': 'invoiced', 'order_count': 15}, | |
{'year': 2021, 'month': 8, 'order_status': 'shipped', 'order_count': 74}, |
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 | |
import pandas as pd | |
s3 = boto3.client("s3") | |
bucket_name = "annageller" | |
s3_object = "sales/customers.csv" | |
obj = s3.get_object(Bucket=bucket_name, Key=s3_object) | |
df = pd.read_csv(obj["Body"]) |
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 | |
bucket_name = "annageller" | |
s3_object = "ted_lasso.txt" | |
s3_object_body = "Be curious, not judgemental" | |
s3_resource = boto3.resource("s3") | |
upload_result = s3_resource.Object(bucket_name, s3_object).put(Body=s3_object_body) | |
assert upload_result["ResponseMetadata"]["HTTPStatusCode"] == 200 |
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 os | |
import boto3 | |
import tempfile | |
S3_BUCKET = "annageller" | |
S3_PREFIX = "sales/" | |
with tempfile.TemporaryDirectory() as tempdir: | |
s3 = boto3.client("s3") | |
response = s3.list_objects_v2(Bucket=S3_BUCKET, Prefix=S3_PREFIX) |
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_name = "annageller" | |
s3_object = "sales/customers.csv" | |
local_file_path = f"/Users/annageller/Desktop/datasets/{s3_object}" | |
# Uploading without specifying content type | |
s3.upload_file( | |
local_file_path, |
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_resource = boto3.resource("s3") | |
list(i for i in s3_resource.Bucket("annageller").objects.all() | |
if i.get()["ContentType"] == "text/csv") |