Load xlsx file from aws lambda using python

0

I developed a custom python lambda function that need to read a xlsx file.

I used openpyxl library. My code use load_workbook in order to read the file

myexcel = openpyxl.load_workbook("test.xlsx")

I created a zip file with root_function and dependencies but the function goes in error when I invoke load_workbook.

xlsx is in the same path of root_function. Is it ok?

Can I read the file or I must load it on S3?

Thanks

luk3tt0
質問済み 3ヶ月前317ビュー
1回答
0

Hello.

I tried it in my environment and was able to upload and read the xlsx file along with Lambda.
The steps are as follows.

mkdir python
cd python
pip install --target ./ openpyxl
vi lambda_function.py

# Include the xlsx file in your python directory.

zip -r ../python.zip .
cd ..
aws lambda update-function-code --function-name test --zip-file fileb://python.zip

In addition to the above method, there is also a method to register openpyxl as a Lambda layer, so please check that as well.
https://repost.aws/questions/QUmvP42wYQRiyOJmvDI5MVtA/error-while-running-python-code-in-aws-lambda-function#ANQ8ctoPV9Q72nMUr5mh8ulg

profile picture
エキスパート
回答済み 3ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ