从R访问S3存储桶 [英] To access S3 bucket from R

查看:98
本文介绍了从R访问S3存储桶的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在AWS的EC2实例上设置了R。
我有很少的csv文件上传到S3存储桶中。
我想知道是否有一种方法可以从R访问S3存储桶中的csv文件。

I have set-up R on an EC2 Instance on AWS. I have few csv files uploaded into a S3 bucket. I was wondering if there is a way to access the csv files in the S3 bucket from R.

任何帮助/指针将不胜感激。

Any help/pointers would be appreciated.

推荐答案

看看混浊的 aws.s3 软件包( https://github.com/cloudyr/aws.s3 ),它可以满足您的需求。不幸的是(在撰写本文时),该软件包还处于早期阶段。有点不稳定。

Have a look at the cloudyr aws.s3 package (https://github.com/cloudyr/aws.s3), it might do what you need. Unfortunately (at time of writing), this package is quite early stage & a little unstable.

仅使用R的 system()命令进行调用,我就取得了很好的成功AWS CLI。

I've 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.


  1. 从这里开始: http://aws.amazon.com/cli/

  2. 使用S3 API列出对象: http://docs.aws.amazon.com/cli/latest /reference/s3api/list-objects.html

  3. 使用S3 API获取对象: http://docs.aws.amazon.com/cli/latest/reference/s3api/get-object.html

  1. Start here: http://aws.amazon.com/cli/
  2. List objects using S3 API: http://docs.aws.amazon.com/cli/latest/reference/s3api/list-objects.html
  3. Get objects using S3 API: http://docs.aws.amazon.com/cli/latest/reference/s3api/get-object.html

例如,在命令行上,请尝试以下操作:

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

在R中,c只需执行以下操作即可:

In R, can just do something like:

system("aws s3api list-objects --bucket some-bucket --query 'Contents[].{Key: Key}' > my_bucket.json")

这篇关于从R访问S3存储桶的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆