How to access files in S3 bucket from R?

0 votes

I have installed R on one of my Amazon EC2 Instance. And I have uploaded few csv files into a S3 bucket. I was wondering if there is a way to access these csv files in the S3 bucket from R.

Any help  would be appreciated.

Aug 10, 2018 in AWS by datageek
• 2,500 points

2 answers to this question.

0 votes

Enter the following command: install.packages("")

Then, use the s3.get() command from there. The Help tab should tell you what goes in for arguments.

answered Aug 10, 2018 by Archana
• 4,150 points
0 votes
You can take a look at the cloudyr aws.s3 package in Github ( ), it is quite related to what you need. Unfortunately, this package is quite early-stage & a little unstable.

I've have had good success simply using R's system() command to make a call to the AWS CLI. This is relatively easy to get started on, very robust, and very well supported.

Start here:

List objects using S3 API:

Get objects using S3 API:

So, for example, on command-line try following:

pip install awscli aws configure aws s3 help aws s3api list-objects --bucket some-bucket --query 'Contents[].{Key: Key}' aws s3api get-object --bucket some-bucket --key some_file.csv new_file_name.csv

In R, can just do something like:

system("aws s3api list-objects --bucket some-bucket --query 'Contents[].{Key: Key}' > my_bucket.json")
answered Aug 10, 2018 by Deepthi
• 300 points

Related Questions In AWS

0 votes
1 answer

How to edit files in the AWS S3 bucket from CLI?

Hi@akhtar, According to my knowledge,  you can't edit ...READ MORE

answered Jun 8 in AWS by MD
• 80,270 points
+3 votes
5 answers

How to move files from amazon ec2 to s3 bucket using command line

Hey, 3 ways you can do this: To ...READ MORE

answered Oct 9, 2018 in AWS by Omkar
• 69,030 points
0 votes
1 answer

how to access AWS S3 from Lambda in VPC

With boto3, the S3 urls are virtual by default, ...READ MORE

answered Sep 28, 2018 in AWS by Priyaj
• 57,700 points
0 votes
1 answer

How to copy .csv file from Amazon S3 bucket?

Boto3 is the library to use for ...READ MORE

answered Jul 6, 2018 in AWS by Priyaj
• 57,700 points
0 votes
1 answer
+5 votes
13 answers

Python AWS Boto3: How do i read files from S3 Bucket?

You can download the file from S3 ...READ MORE

answered Dec 7, 2018 in AWS by Jino
0 votes
1 answer

How to download the latest file in a S3 bucket using AWS CLI?

You can use the below command $ aws ...READ MORE

answered Sep 6, 2018 in AWS by Archana
• 4,150 points