[R] if url.exists() or not
veepsirtt
veepsirtt at gmail.com
Fri Nov 9 07:32:05 CET 2012
Hi Rusers,
the file is available for download but it returns not exists.
How to download the files?
thanks
veepsirtt
> #################################################################
> ######### check for if file exist or not
> #################################################################
> niftyquotes <- function(ndays){
+ library(RCurl)
+ endDate =Sys.Date()
+ startDate = as.Date(endDate-ndays, order="ymd")
+
+ start1<-format(startDate,"%d-%m-%Y")
+ end1<-format(endDate ,"%d-%m-%Y")
+
+
a=paste("http://nseindia.com/content/indices/histdata/S&P%20CNX%20NIFTY",start1,"-",end1,".csv",sep="")
+
+ if (url.exists(a)){
+
+ # return(print(paste(start1,"file exist")))
+ }
+ else {
+ return(print(paste(start1,"Not exist ********")))
+ }
+
+ }
>
> # find for last 30 days
> N=30
> for (i in 1:N){
+ niftyquotes(i)
+ }
[1] "03-11-2012 Not exist ********"
[1] "30-10-2012 Not exist ********"
[1] "28-10-2012 Not exist ********"
[1] "27-10-2012 Not exist ********"
[1] "26-10-2012 Not exist ********"
[1] "22-10-2012 Not exist ********"
[1] "20-10-2012 Not exist ********"
[1] "19-10-2012 Not exist ********"
[1] "18-10-2012 Not exist ********"
[1] "17-10-2012 Not exist ********"
[1] "15-10-2012 Not exist ********"
[1] "14-10-2012 Not exist ********"
[1] "13-10-2012 Not exist ********"
[1] "12-10-2012 Not exist ********"
[1] "11-10-2012 Not exist ********"
>
>
--
View this message in context: http://r.789695.n4.nabble.com/if-url-exists-or-not-tp4648840p4649006.html
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list