[R] download/retain text file structure with RCurl/getURL()

Gabor Grothendieck ggrothendieck at gmail.com
Mon Jan 19 19:38:21 CET 2009


If you are having problems with the default download.file method you
can try method = "wget":

f <- "ftp://ftp.wcc.nrcs.usda.gov/data/snow/snow_course/table/history/idaho/13e19.txt"
download.file(f, basename(f), method = "wget")


On Mon, Jan 19, 2009 at 1:26 PM, zack holden <zack_holden at hotmail.com> wrote:
>
> Dear list,
>
> I'm trying to download a text file directly from the internet using the RCurl package and the command getURL. Duncan Lang graciously helped me solve the first step in this problem using the following command:
>
> #################
> txtfile <- getURL('ftp://ftp.wcc.nrcs.usda.gov/data/snow/snow_course/table/history/idaho/13e19.txt',
> ftp.use.epsv = FALSE)
> #################
>
> This brings the text file into R in a single long character string. I've spent many hours now trying to bring this text file into R into a sensible form. I've tried every variant of different commands in getURL help file, as well as different
> strsplit() commands to try to break this character string into a sensible rows and columns, to no avail.
>
> Can anyone suggest a solution for doing this? I suspect there is a getURL command I'm missing. Alternatively, do I really have to break this long character string into rows and columns that I can then assemble into a table?
>
> I'd be grateful for any advice.
>
> Thanks in advance,
>
> Zack
>
>
> ______________________________________________
> R-help at 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.
>




More information about the R-help mailing list