我想能夠使用R.正確的參數下載文件使用Amazon S3 API GET請求
我已經使用被記錄在這裏http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTObjectGET.html
的API開始了我的亞馬遜S3存儲下載.csv
文件
我正在使用包httr
來創建GET
請求,我只需要確定能夠下載相關文件的正確參數。
我已經設置了response-content-type
到text/csv
,因爲我知道它.csv
文件,我希望能下載...但我得到的迴應如下:
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
,沒有文件被下載和數據似乎在響應中......我可以提取在響應中創建的代表數據的字符串,我想盡一切努力可以將它轉換爲最初所期望的data.frame
,但有沒有更好的方法下載數據...直接從GET
命令,然後使用read.csv
來讀取數據?我認爲這是一個參數問題......只是不確定需要爲要下載的文件設置哪些參數。
如果有人建議字符串的轉換...這是我有字符串的結構...我需要做些什麼命令才能將它轉換爲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__
感謝
HLM
你有代碼,並可能被用於測試可公開訪問的網址是什麼? –
我發現了一個類似的結構。查看直接從'GET'值讀取和使用'colClasses ='提高性能的組合。 –