Carlos Aguni

Highly motivated self-taught IT analyst. Always learning and ready to explore new skills. An eternal apprentice.


Lambda read excel from S3

07 Jun 2020 » programming
pip3 install xlrd pandas s3fs
import json
import s3fs
import pandas as pd

def lambda_handler(event, context):
    
    s3fs_obj = s3fs.S3FileSystem()
    df = pd.read_excel("s3://<bucket/<key>", filesystem=s3fs_obj)
    pritn(df.head())
    
    return {
        'statusCode': 200,
        'body': json.dumps('Hello from Lambda!')
    }