Answers for "export excel file to s3 python"

1

how to download excel file from s3 using python

import boto3

BUCKET_NAME = 'Enter Your Bucket Name'
BUCKET_FILE_NAME = 'Enter File To be download'
LOCAL_FILE_NAME = 'Local File Name'

def download_s3_file():
    s3 = boto3.client('s3')
    s3.download_file(BUCKET_NAME, BUCKET_FILE_NAME, LOCAL_FILE_NAME)
Posted by: Guest on April-02-2021
0

export excel file to s3 python

import io
import boto3
import xlsxwriter
import pandas as pd

bucket = 'your-s3-bucketname'
filepath = 'path/to/your/file.format'
df = pd.DataFrame({'Data': [10, 20, 30, 20, 15, 30, 45]})

with io.BytesIO() as output:
    with pd.ExcelWriter(output, engine='xlsxwriter') as writer:
        df.to_excel(writer, 'sheet_name')
    data = output.getvalue()
s3 = boto3.resource('s3')
s3.Bucket(bucket).put_object(Key=filepath, Body=data)
Posted by: Guest on September-27-2021

Python Answers by Framework

Browse Popular Code Answers by Language