R/fwf2csv.R

Defines functions fwf2csv

Documented in fwf2csv

fwf2csv <- function(fwffile, csvfile, names, begin, end, verbose = getOption("verbose"))
{
    # Check for errors
    ncols = length(names)
    if(length(begin) != ncols || length(end) != ncols)
	stop("The vectors \"names\", \"begin\" and \"end\" must have the same length.")
    if(file.exists(fwffile) == FALSE){
	msg <- paste(gettext("File not found:", domain = "R-descr"), fwffile)
	stop(msg)
    }

    csvfile <- path.expand(csvfile)
    fwffile <- path.expand(fwffile)

    .C(realfwf2csv,
	as.character(fwffile),
	as.character(csvfile),
	as.character(names),
	as.integer(begin),
	as.integer(end),
	ncols,
        as.logical(verbose))

    return (invisible(NULL))
}

Try the descr package in your browser

Any scripts or data that you put into this service are public.

descr documentation built on Nov. 28, 2023, 1:10 a.m.