I've got a zip file in S3 bucket called 'My_Bucket'. the file key is 'MY_FILE.ZIP'. The extracted file name is 'MY_FILE_FULL_NAME.CSV'. I would like to get the file from the S3 bucket, extract it and iterate it. As the job will be done by Lambda function - I would like to extract the file in memory (stream). I started to write the below: import zipfile import boto3 import io
s3 = boto3.resource("s3")
bucket = s3.Bucket('My_Bucket')
obj = bucket.Object('YYY.zip')
with io.BytesIO(obj.get()["Body"].read()) as tf:
tf.seek(0)
#How should I continue ???
I need the part from unzipping through opening the file, reading it line by line.
Thanks in advance.