I would like to be able to download a .csv
file from my Amazon S3 bucket using R.
I have started using the API that is documented here http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectGET.html
I am using the package httr
to create the GET
request, I just need to work out what the correct parameters are to be able to download the relevant file.
I have set the response-content-type
to text/csv
as I know its a .csv
file I hope to download...but the response I get is as follows:
Response [https://s3-zone.amazonaws.com/bucket.name/file.name.csv?response-content-type=text%2Fcsv]
Status: 200
Content-type: text/csv
Date and Time,Open,High,Low,Close,Volume
2007/01/01 22:51:00,5683.00,5683.00,5673.00,5673.00,64
2007/01/01 22:52:00,5675.00,5676.00,5674.00,5674.00,17
2007/01/01 22:53:00,5674.00,5674.00,5673.00,5674.00,42
2007/01/01 22:54:00,5675.00,5676.00,5674.00,5676.00,36
2007/01/01 22:55:00,5675.00,5676.00,5675.00,5676.00,18
2007/01/01 22:56:00,5676.00,5677.00,5674.00,5677.00,64
2007/01/01 22:57:00,5678.00,5678.00,5677.00,5677.00,45
2007/01/01 22:58:00,5679.00,5680.00,5678.00,5680.00,30
.../01/01 22:59:00,5679.00,5679.00,5677.00,5678.00,19
And no file is downloaded and the data seems to be in the response...I can extract the string of characters that is created in the response, which represents the data, and I guess with some effort it can be converted into a data.frame
as originally desired, but is there a better way of downloading the data...straight from the GET
command, and then using read.csv
to read the data? I think that it is a parameter issues...just not sure what parameters need to be set for the file to be downloaded.
If people suggest the conversion of the string...This is the structure of the string I have...what commands would I need to do to convert it into a data.frame
?
chr "Date and Time,Open,High,Low,Close,Volume\r\n2007/01/01 22:51:00,5683.00,5683.00,5673.00,5673.00,64\r\n2007/01/01 22:52:00,5675."| __truncated__
Thanks
HLM