I have written a function in Python to analyse documents and retrieve key-value pairs from forms in these documents. Below is just the handler bit of it.
def handler(event, context):
bucket = event['Records'][0]['s3']['bucket']['name']
key = urllib.parse.unquote_plus(event['Records'][0]['s3']['object']['key'], encoding='utf-8')
try:
document = TTFunction(bucket,key)
KVpairs=[]
for page in document.pages:
KVpairs= output(page)
When I print the output of this function, it is in JSON. Is there a way to save this output as a JSON or a CSV in the same bucket?