Attempting to save an xlsx file to an s3 bucket using the following method:
import io
import pronounceable
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)
However this results in the following error:
No module named 'xlsxwriter': ModuleNotFoundError
I have tried to install xlsxwriter as a layer to my lamdbda function (as I have with other packages/modules) but it seems I am already using the allocated amount of file space for layers.
Layers consume more than the available size of 262144000 bytes
QUESTION
Is there anyway I export the file without xlsxwriter or otherwise increase the allocated space for layers so that I can add it?
question from:
https://stackoverflow.com/questions/65911211/error-when-attempting-to-save-xlsx-file-to-s3-bucket 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…