On 5/10/2009, at 2:49 PM, stephen sefick wrote:

http://waterdata.usgs.gov/nwis/uv? format=rdb&period=7&site_no=021973269

I would like to be able to parse this file up:

I can do this
x <- read.table("http://waterdata.usgs.gov/nwis/uv? format=rdb&period=7&site_no=021973269",
skip=26)

but If I add another gauge to this

x <- read.table("http://waterdata.usgs.gov/nwis/uv? format=rdb&period=7&site_no=021973269,06018500",
skip=26)
It does not work because there are two files appended to each other.

It would be easy enough to write the code so that each individual
gauge would be read in as a different file, but is there a way to get
this information in using the commented part of the file to give the
headers?  This is probably a job for some other programing language
like perl, but I don't know perl.

any help would be very helpful.

I'm completely clear what's going on here --- (a) I'm not sure what you mean by ``using the commented part of the file to give the headers''; the headers are not ``commented'', and (b) I'm puzzled by the fact that there are 9 column
headers/field names, but only 7 columns/fields.

Be that as it were, here's what I'd do:

x <- read.table("http://waterdata.usgs.gov/nwis/uv? format=rdb&period=7&site_no=021973269",
                 skip=23,nrows=1,header=TRUE,check.names=FALSE)
y <- read.table("http://waterdata.usgs.gov/nwis/uv? format=rdb&period=7&site_no=021973269",skip=26)
names(y) <- names(x)[1:7]

This ***appears*** to give a reasonably sensible data frame.

Is this anything like what you want?

        cheers,

                Rolf Turner

######################################################################
Attention:\ This e-mail message is privileged and confid...{{dropped:9}}

______________________________________________
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