Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: loop: how can I download CSV files and append it


From   Daniel Marcelino <[email protected]>
To   [email protected]
Subject   st: loop: how can I download CSV files and append it
Date   Sat, 19 Mar 2011 17:48:58 -0300

Hello all,
I am wondering if someone could point me the way to get each .CSV file
from a website list stored in a column say "sites" and also
aggregating it in a master file like "big.data".
I perfomed this task using R package, but I prefer do the same work on Stata.

So, basically I need to download files which web addresses are in each
row of column "sites". After read a file, it need to be appended to
the left one until finished the web adresses, so the output
big.data.dta must be all raw data found at websites.

big.data <- NULL
base <-NULL

for (i in sites) {
try(base <- read.csv2(i, header=T, as.is=T), TRUE)
if(!is.null(base)) big.data <- rbind(big.data, base)
write.table(big.data, file ="ap.csv",
sep=";", row.names=F, na="")
}
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index