Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
dschlaep opened this issue Sep 23, 2016 · 0 comments

Comments

@dschlaep
Copy link

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]).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant