Last active
January 12, 2023 09:42
-
-
Save anna-geller/279ba90e4fc3aebe04e55d16598804ca 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 | |
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}, | |
{'year': 2021, 'month': 8, 'order_status': 'canceled', 'order_count': 34}, | |
{'year': 2021, 'month': 8, 'order_status': 'processing', 'order_count': 29}]) | |
df.to_html(html_file, index=False) | |
s3 = boto3.client("s3") | |
s3.upload_file( | |
Filename=html_file, | |
Bucket=s3_bucket, | |
Key=html_file, | |
ExtraArgs={"ContentType": "text/html", "ACL": "public-read"}, | |
) | |
# URL that you can share with others | |
print(f"http://{s3_bucket}.s3.amazonaws.com/{html_file}") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment