2

I am trying to read data from PDF stored in S3 bucket, convert it to text and then dump these text into json file.

Finally I want to upload this json file to elastic search for indexing.

I have written below code snippet for doing this:

with open('data.json','w') as f:
        json.dump(doc,f)
        dataj=json.load(f)
        doc_data=dataj[:]

doc is the text which I have extracted using pdfminer. when executing this code I'm getting below error.

[Errno 30] Read-only file system: 'data.json': IOError
Traceback (most recent call last):
File "/var/task/lambda_function.py", line 56, in lambda_handler
raise e
IOError: [Errno 30] Read-only file system: 'data.json'.

Someone please help me in finding what I'm doing wrong here.

1 Answer 1

3

You're trying to write a file where is not permitted.

Lambda currently only supports writing files to the /tmp directory.

with open('/tmp/data.json','w') as f:
        json.dump(doc,f)
        dataj=json.load(f)
        doc_data=dataj[:]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.