Learn R Programming

rdwd (version 1.8.0)

createIndex: Create file and meta index of the DWD CDC FTP Server

Description

This is mainly an internal function. Create data.frames out of the vector index returned by indexFTP(). For fileIndex (the first output element) createIndex tries to obtain res, var, per, file, id, start and end from the paths. If meta=TRUE, metaIndex and geoIndex are also created. They combine all Beschreibung files into a single data.frame.
If you create your own index as suggested in selectDWD (argument findex), you can read the produced file as shown in the example section.

Usage

createIndex(
  paths,
  base = dwdbase,
  dir = "DWDdata",
  fname = "fileIndex.txt",
  meta = FALSE,
  metadir = "meta",
  mname = "metaIndex.txt",
  gname = "geoIndex.txt",
  overwrite = FALSE,
  checkwarn = TRUE,
  checklog = tempfile(),
  quiet = rdwdquiet(),
  ...
)

Value

invisible data.frame (or if meta=TRUE, list with two data.frames) with a number of columns inferred from the paths. Each is also written to disc.

Arguments

paths

Char: vector of DWD paths returned by indexFTP() called with the same base value as this function

base

Main directory of DWD ftp server, defaulting to observed climatic records. DEFAULT: dwdbase

dir

Char: writeable directory name where to save the main output(s). Created if not existent. DEFAULT: "DWDdata" at current getwd()

fname

Char: Name of file in dir in which to write fileIndex. Use fname="" to suppress writing. DEFAULT: "fileIndex.txt"

meta

Logical: should metaIndex also be created from fileIndex? Uses dataDWD() to download files if not present. DEFAULT: FALSE

metadir

Char: Directory (subfolder of dir) where original description files are downloaded to if meta=TRUE. Passed to dataDWD(). "" to write in dir. DEFAULT: "meta"

mname

Char: Name of file in dir (not metadir) in which to write metaIndex. Use mname="" to suppress writing. DEFAULT: "metaIndex.txt"

gname

Filename for geoIndex. DEFAULT: "geoIndex.txt"

overwrite

Logical: Overwrite existing fname / mname / gname files? If not, "_n" is added to the filenames, see berryFunctions::newFilename(). DEFAULT: FALSE

checkwarn

Logical: warn about checkIndex() issues? DEFAULT: TRUE

checklog

Logfile for checkIndex(). DEFAULT: tempfile()

quiet

Logical: Suppress messages about progress and filenames? DEFAULT: FALSE through rdwdquiet()

...

Further arguments passed to dataDWD() for the meta part.

Author

Berry Boessenkool, berry-b@gmx.de, Oct-Nov 2016, June 2017

See Also

indexFTP(), updateIndexes(), index, selectDWD(), website index chapter

Examples

Run this code
if (FALSE)  # Not tested with R CMD check because of file writing
link <- "daily/kl/historical/tageswerte_KL_00699_19490101_19580630_hist.zip"
ind <- createIndex(link, dir=tempdir())
ind
# res  var        per  id    start          end ismeta
# daily kl historical 699 1949-01-01 1958-06-30 FALSE
link2 <- "daily/kl/historical/KL_Tageswerte_Beschreibung_Stationen.txt"
link3 <- "daily/kl/recent/KL_Tageswerte_Beschreibung_Stationen.txt"
ind2 <- createIndex(c(link,link2,link3), dir=tempdir(), meta=TRUE, checkwarn=FALSE)
lapply(ind2, head)
link4 <- "1_minute/precipitation/meta_data/Meta_Daten_ein_min_rr_00755.zip"
ind <- createIndex(link4, dir=tempdir())
ind


Run the code above in your browser using DataLab