export excel file to s3 python

Solutions on MaxInterview for export excel file to s3 python by the best coders in the world

showing results for - "export excel file to s3 python"
Jojo
22 May 2016
1import boto3
2
3BUCKET_NAME = 'Enter Your Bucket Name'
4BUCKET_FILE_NAME = 'Enter File To be download'
5LOCAL_FILE_NAME = 'Local File Name'
6
7def download_s3_file():
8    s3 = boto3.client('s3')
9    s3.download_file(BUCKET_NAME, BUCKET_FILE_NAME, LOCAL_FILE_NAME)
Juan Manuel
21 May 2020
1import io
2import boto3
3import xlsxwriter
4import pandas as pd
5
6bucket = 'your-s3-bucketname'
7filepath = 'path/to/your/file.format'
8df = pd.DataFrame({'Data': [10, 20, 30, 20, 15, 30, 45]})
9
10with io.BytesIO() as output:
11    with pd.ExcelWriter(output, engine='xlsxwriter') as writer:
12        df.to_excel(writer, 'sheet_name')
13    data = output.getvalue()
14s3 = boto3.resource('s3')
15s3.Bucket(bucket).put_object(Key=filepath, Body=data)