[英]To access S3 bucket from R
I have set-up R on an EC2 Instance on AWS. 我在AWS上的EC2实例上设置了R。 I have few csv files uploaded into a S3 bucket.
我有很少的csv文件上传到S3存储桶。 I was wondering if there is a way to access the csv files in the S3 bucket from R.
我想知道是否有办法从R访问S3存储桶中的csv文件
Any help/pointers would be appreciated. 任何帮助/指针将不胜感激。
Have a look at the cloudyr aws.s3
package ( https://github.com/cloudyr/aws.s3 ), it might do what you need. 看看cloudyr
aws.s3
软件包( https://github.com/cloudyr/aws.s3 ),它可能会满足您的需求。 Unfortunately (at time of writing), this package is quite early stage & a little unstable. 不幸的是(在撰写本文时),这个包很早就有点不稳定了。
I've had good success simply using R's system()
command to make a call to the AWS CLI. 仅使用R的
system()
命令调用AWS CLI,我就取得了很大的成功。 This is relatively easy to get started on, very robust and very well supported. 这相对容易上手,非常强大且得到很好的支持。
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: 在R中,可以执行以下操作:
system("aws s3api list-objects --bucket some-bucket --query 'Contents[].{Key: Key}' > my_bucket.json")
Enter the following command: install.packages("AWS.tools")
输入以下命令:
install.packages("AWS.tools")
From there, use the s3.get()
command. 从那里,使用
s3.get()
命令。 The Help
tab should tell you what goes in for arguments. “
Help
选项卡应该告诉您参数的内容。
安装libdigest-hmac-perl
包;
sudo apt-get install libdigest-hmac-perl
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.