I have a working code in Jupyter notebook to transpose a CSV file. Trying similar thing in AWS Lambda and not working.
Here is my source file.
name,address,phone
john,chicago,1111111111
doe,newyork,2222222222
expected output -->
name,john,doe,
address,chicago,newyork
phone,1111111111,2222222222
Here is my working code in Jupyter
import numpy as np
with open('/Users/test/Desktop/python/pythonnew.txt') as file:
lis = [x.replace('\n', '').split(',') for x in file]
x = np.array(lis)
print(x.T)
Trying similarly in Lambda and it's not working. Here is my lambda python code.
import boto3
import numpy as np
s3 = boto3.client('s3')
def lambda_handler(event, context):
data = s3.get_object(Bucket='s3dummy', Key='input/input.txt')
contents = data['Body'].read()
output = contents.decode('utf-8')
lis = [x.split(',') for x in output]
x = np.array(lis)
print(x.T)
Any help is greatly appreciated. I am a newbie to AWS as well as Python. So, I apologize in advance if this easy and for wasting your time