[R] Download a file from url

veepsirtt veepsirtt at gmail.com
Sun Nov 18 02:07:32 CET 2012


Hi R,
I installed wget and tried to download the file from this 
http://nseindia.com/content/equities/scripvol/datafiles/16-11-2012-TO-16-11-2012ACCEQN.csv
but it fails.
How to get it using wget?
thanks
veepsirtt


#Define Working Directory, where files would be saved
setwd('G:/NIFTY')

#Define start and end dates, and convert them into date format
startDate = as.Date("2011-01-05", order="ymd")
endDate = as.Date("2011-02-01", order="ymd")

f <- tempfile() 

	downloadfilename=paste("ACC", "EQN", sep = "")
	temp =""

 	#Generate URL
http://nseindia.com/content/equities/scripvol/datafiles/16-11-2012-TO-16-11-2012ACCEQN.csv

	myURL = paste("http://nseindia.com/content/equities/scripvol/datafiles/",
as.character(startDate, "%d-%m-%Y"), "-TO-", as.character(endDate,
"%d-%m-%Y"), downloadfilename, ".csv", sep = "")
	

  download.file(myURL, f, method='wget', extra="-U 'Mozilla/5.0 (X11; Linux)
Gecko Firefox/5.0'") 
		
		temp <- read.csv(f, sep = ",") 
head(temp)









--
View this message in context: http://r.789695.n4.nabble.com/Download-a-file-from-url-tp4642985p4649907.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list