I tried to read s3 files using boto3
the code used is below
content = s3.Object('bucket','objectkey').get()['Body'].read()
StringVariable=content.decode('UTF-8','ignore')
x = StringVariable.split('\n')
str1 = ''.join(str(e) for e in x)
print(str1)
it gets all the lines as bytes so i used decode and stored as string.
the output needed is only the first 5 lines to be read and stored as string.
thanks in advance.