Last active
February 20, 2021 23:41
-
-
Save onelharrison/8ab769cef13da68ead4a578c887dfb2b to your computer and use it in GitHub Desktop.
Demo script for reading a CSV file from S3 into a pandas data frame using s3fs-supported pandas APIs
This file contains hidden or 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
""" | |
Demo script for reading a CSV file from S3 into a pandas data frame using s3fs-supported pandas | |
APIs | |
""" | |
import os | |
import pandas as pd | |
AWS_S3_BUCKET = os.getenv("AWS_S3_BUCKET") | |
AWS_ACCESS_KEY_ID = os.getenv("AWS_ACCESS_KEY_ID") | |
AWS_SECRET_ACCESS_KEY = os.getenv("AWS_SECRET_ACCESS_KEY") | |
AWS_SESSION_TOKEN = os.getenv("AWS_SESSION_TOKEN") | |
key = "files/books.csv" | |
books_df = pd.read_csv( | |
f"s3://{AWS_S3_BUCKET}/{key}", | |
storage_options={ | |
"key": AWS_ACCESS_KEY_ID, | |
"secret": AWS_SECRET_ACCESS_KEY, | |
"token": AWS_SESSION_TOKEN, | |
}, | |
) | |
print(books_df) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment