Skip to content

read.csv.raw fails if all rows are skipped and if colClasses are absent -- unlike utils::read.csv #30

@dschlaep

Description

@dschlaep

Calling read.csv.raw will fail if all rows are skipped and if colClasses are absent. The built-in function utils::read.csv after which the interface of the really great and fast iotools::read.csv.raw is modelled, does not fail. Would it be possible to catch this admittedly special case which, in my case, would make programming a bit easier?

Many thanks,
Daniel

A short reproducible example:

packageVersion("iotools")   # ‘0.2.3’
x <- matrix(sample(100), ncol = 10)
write.csv(x, file = "test.csv", row.names = FALSE)

read.csv("test.csv", skip = 10)                                             # dim == c(0, 11)
read.csv("test.csv", skip = 10, colClasses = rep("integer", 10))            # dim == c(0, 11)
read.csv.raw("test.csv", skip = 10)    # Error in subset[, i] : subscript out of bounds
read.csv.raw("test.csv", skip = 10, colClasses = rep("integer", 10))        # dim == c(0, 11)

unlink("test.csv")

By the way, I prefer the real/expected column names which are returned by read.csv.raw whenever colClasses are specified compared to the unexpected column names returned by read.csv ('X' concatenated with the values of the last and here skipped line [-- instead of "The default is to use "V" followed by the column number" quoting ?read.csv]).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions