Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Down load data from HTTPS in R

Tags:

r

https

download

I have a problem with downloading data from HTTPS in R, I try using curl, but it doesn't work.

URL <- "https://github.com/Bitakhparsa/Capstone/blob/0850c8f65f74c58e45f6cdb2fc6d966e4c160a78/Plant_1_Generation_Data.csv"

options('download.file.method'='curl')
download.file(URL, destfile = "./data.csv", method="auto")

I downloaded the CSV file with that code, but the format was changed when I checked the data. So it didn't download correctly. Would you please someone help me?

like image 551
bitap Avatar asked Mar 10 '26 22:03

bitap


1 Answers

I think you might actually have the URL wrong. I think you want:

https://raw.githubusercontent.com/Bitakhparsa/Capstone/0850c8f65f74c58e45f6cdb2fc6d966e4c160a78/Plant_1_Generation_Data.csv

Then you can download the file directly using library(RCurl) rather than creating a variable with the URL

library(RCurl)
download.file("https://raw.githubusercontent.com/Bitakhparsa/Capstone/0850c8f65f74c58e45f6cdb2fc6d966e4c160a78/Plant_1_Generation_Data.csv",destfile="./data.csv",method="libcurl")

You can also just load the file directly into R from the site using the following

URL <- "https://github.com/Bitakhparsa/Capstone/blob/0850c8f65f74c58e45f6cdb2fc6d966e4c160a78/Plant_1_Generation_Data.csv"
out <- read.csv(textConnection(URL))
like image 90
neuron Avatar answered Mar 13 '26 13:03

neuron



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!