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

Error when skipping lines in text file #29

Closed
SamGG opened this issue Mar 9, 2020 · 2 comments
Closed

Error when skipping lines in text file #29

SamGG opened this issue Mar 9, 2020 · 2 comments
Assignees
Labels

Comments

@SamGG
Copy link

SamGG commented Mar 9, 2020

Hi,
Thanks for this package.
I guess that the beginning of the code L24-L35 is guessing the right parameters for read.table. But then read.table L38 is not applied to the raw file but to already processed text lines. Because skipping lines already took place, it should not be applied twice. I think that the file name actually should be given to read.table L38 instead of the text variable.
Best.

text <- readLines(file, encoding=encoding)
text <- tail(text, length(text) - skip)
text <- text[!startsWith(trimws(text), comment.char)]
if (is.null(sep)) {
sep <- .autoSep(text)
}
if (is.null(header)) {
header <- .autoHeader(text, sep=sep)
}
## load ms file
s <- read.table(text=text, header=header, sep=sep, skip=skip,
comment.char=comment.char, stringsAsFactors=FALSE, ...)

@sgibb
Copy link
Owner

sgibb commented Mar 9, 2020

Dear @SamGG thanks for the bug report! You are right the skip is done twice.

I think that the file name actually should be given to read.table L38 instead of the text variable.

In that case the file would be read twice (readLines and read.table) which would be unnecessary. I will just ignore the skip argument in read.table.

@sgibb sgibb self-assigned this Mar 9, 2020
@sgibb sgibb added the bug label Mar 9, 2020
@sgibb sgibb closed this as completed in cc0857e Mar 9, 2020
@SamGG
Copy link
Author

SamGG commented Mar 9, 2020

Thanks for considering my report.
Best.

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

No branches or pull requests

2 participants