frictionlessdata / forum

🗣 Frictionless Data Forum esp for "How do I" type questions
https://frictionlessdata.io/
10 stars 0 forks source link

How to read the file from s3 bucket using tabulator? #65

Closed Swarnitha-eluru closed 4 years ago

Swarnitha-eluru commented 4 years ago

I wrote a small snippet to read the file given from s3 bucket. from tabulator import Stream source='s3://bucket/data.csv' with Stream(source,headers=1) as stream: print(stream.read()) I gave the object url for the file which has public access ,I am able to read.If I gave the file which doesnot have public access and if the credentials are available.Then where should I pass them.I am facing the below error. image

Is there a way to read the file from s3 bucket which dont have public access but the aws access key id and aws secret access key were available.Where to pass them to read the file?

roll commented 4 years ago

Hi @Swarnitha-eluru,

tabulator uses boto3 under the hood so you can use various methods - https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html

For example, setting env vars should work:

import os

os.environ["AWS_ACCESS_KEY_ID"] = "<you_id>"
os.environ["AWS_SECRET_ACCESS_KEY"] = "<your_key>"

# use tabulator
Swarnitha-eluru commented 4 years ago

okay my doubt was If a url was given from s3 ,that file has no public access.If I give those credentials can I read it? using this import os

os.environ["AWS_ACCESS_KEY_ID"] = "" os.environ["AWS_SECRET_ACCESS_KEY"] = ""

use tabulator

roll commented 4 years ago

@Swarnitha-eluru After providing credentials you should be able to access S3 based on those credentials permissions. If they can read private you will be able to read private

Swarnitha-eluru commented 4 years ago

okay thank you.

Swarnitha-eluru commented 4 years ago

Hi @roll ,its working .Thanks for your support.