Category : aws-lambda

In a jupyter notebook I am able to create two Pandas dataframes and export them to individual sheets of an Excel workbook with some additional formatting, including text-wrapping, frozen pane, bold headers and auto-filters. Code below: # MODULES import pandas as pd import numpy as np from datetime import date #CONSTRUCT DATAFRAME df = pd.DataFrame({‘Data’: ..

Read more

How to rename multiple output files in S3 bucket. As an example I am using os.path.basename(keyprefix),’w’ to write the file which is of pattern abc_00000.csv.gz abc_00001.csv.gz I want to rename the above files with naming convention: abc_{today date in YYYYMMDD format}00.csv.gz abc{today date in YYYYMMDD format}_01.csv.gz Below is the code for reference: import boto3 import ..

Read more

I am creating a lambda function that adds data from a .csv file in AWS S3 to DynamoDB using the following Python code: import boto3 s3 = boto3.client("s3") dynamodb = boto3.resource("dynamodb") def lambda_function(event, context): bucket = event[‘Records’][0][‘s3’][‘bucket’][‘name’] key = event[‘Records’][0][‘s3’][‘object’][‘key’] obj = s3.get_object(Bucket=bucket, Key=key) rows = obj[‘Body’].read().split(b’n’) table = dynamodb.Table(‘Sports_Scores’) with table.batch_writer() as batch: for ..

Read more