Hi,

#################################################################
######### 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] "07-11-2012 file exist"
[1] "06-11-2012 file exist"
[1] "05-11-2012 file exist"
[1] "04-11-2012 file exist"
[1] "03-11-2012 Not exist ********"
[1] "02-11-2012 file exist"
[1] "01-11-2012 file exist"
[1] "31-10-2012 file exist"
[1] "30-10-2012 file exist"
[1] "29-10-2012 file exist"
[1] "28-10-2012 file exist"
[1] "27-10-2012 Not exist ********"
[1] "26-10-2012 file exist"
[1] "25-10-2012 Not exist ********"
[1] "24-10-2012 file exist"
[1] "23-10-2012 Not exist ********"
[1] "22-10-2012 Not exist ********"
[1] "21-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] "16-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 ********"
[1] "10-10-2012 file exist"
[1] "09-10-2012 Not exist ********"
> 
> 


[1] "04-11-2012 file exist" is sunday how it shows file exist?
please help me
with regards
veepsirtt





--
View this message in context: 
http://r.789695.n4.nabble.com/if-url-exists-or-not-tp4648840.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to