Skip to main content

A Python toolkit to simplify common operations between S3 and Pandas.

Project description

S3 DataKit 🧰

A Python toolkit to simplify common operations between Amazon S3 and Pandas DataFrames.

Key Features

  • List files in an S3 bucket.
  • Upload local files to S3.
  • Download files from S3 directly to a local path or a Pandas DataFrame.
  • Supports CSV and Stata (.dta) when reading into DataFrames.

Installation

pip install s3-datakit

Credential Configuration

This package uses boto3 to interact with AWS. boto3 will automatically search for credentials in the following order:

  1. Environment variables (AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, etc.).
  2. The AWS CLI credentials file (~/.aws/credentials).
  3. IAM roles (if running on an EC2 instance or ECS container).

For local development, the easiest method is to use a .env file.

1. Install python-dotenv in your project (not as a library dependency):

pip install python-dotenv

2. Create a .env file in your project's root:

AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY
AWS_SECRET_ACCESS_KEY=YOUR_SECRET_KEY
AWS_DEFAULT_REGION=your-region # e.g., us-east-1

3. Load the variables in your script before using s3datakit:

from dotenv import load_dotenv
import s3datakit as s3dk

# Load environment variables from .env
load_dotenv()

# Now you can use the package's functions
s3dk.list_s3_files(bucket="my-bucket")

Usage

List Files

import s3datakit as s3dk

file_list = s3dk.list_s3_files(bucket="my-data-bucket")
if file_list:
    print(file_list)

Upload a File

import s3datakit as s3dk

s3dk.upload_s3_file(
    local_path="reports/report.csv",
    bucket="my-data-bucket",
    s3_path="final-reports/report_2025.csv"
)

Download a File

Option 1: Download to a local path

import s3datakit as s3dk

local_file = s3dk.download_s3_file(
    bucket="my-data-bucket",
    s3_path="final-reports/report_2025.csv",
    local_path="downloads/report.csv"
)
print(f"File downloaded to: {local_file}")

Option 2: Download directly to a Pandas DataFrame

import s3datakit as s3dk

df = s3dk.download_s3_file(
    bucket="my-data-bucket",
    s3_path="stata-data/survey.dta",
    local_path="temp/survey.dta",
    to_df=True
)
print(df.head())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

s3_datakit-0.1.0.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

s3_datakit-0.1.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file s3_datakit-0.1.0.tar.gz.

File metadata

  • Download URL: s3_datakit-0.1.0.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for s3_datakit-0.1.0.tar.gz
Algorithm Hash digest
SHA256 5e59bae438eecb39cec611e90235ac67b5e2c854c9535ebf0b39b4aacbf2210e
MD5 f7950e525c650f55fd5e596cd1ede8de
BLAKE2b-256 94780d5b0ccd462e10c1b74ab09e47ff10124b8511b32c21cb86ac6ffda81d17

See more details on using hashes here.

File details

Details for the file s3_datakit-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: s3_datakit-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for s3_datakit-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 738a83448b32ec39419dd6d248a7278351a60e2bd0bc887f84aa45b2d8d61caf
MD5 e01c5de8370a1652138d2dc01396b1c3
BLAKE2b-256 e9acf595096f59ee054d689929d783b45b12f3a6d592daf0aa4d0b1c8d68a0c0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page