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

Expose parsed ref string #22

Open
jennybc opened this issue May 25, 2016 · 1 comment
Open

Expose parsed ref string #22

jennybc opened this issue May 25, 2016 · 1 comment

Comments

@jennybc
Copy link
Member

jennybc commented May 25, 2016

This is going to be handy elsewhere:

Make sure I can get Sheet1 from reasonable representations of Sheet1!$B$2:$B$11.

@jennybc
Copy link
Member Author

jennybc commented May 25, 2016

Upon further thought, I think I need to make parse_ref_string() nicer and export it:

parse_ref_string <- function(x, fo = NULL) {
parsed <- as.list(rematch::re_match(.cr$string_rx, x)[1, , drop = TRUE])
names(parsed) <- c("input", "file", "sheet", "ref", "invalid")
parsed$ref_v <- unlist(strsplit(parsed$ref, ":"))
stopifnot(length(parsed$ref_v) %in% 1:2)
if (is.null(fo)) {
fo_v <- guess_fo(parsed$ref_v)
parsed$fo <- unique(fo_v)
if (length(parsed$fo) > 1) {
stop("Cell references aren't uniformly A1 or R1C1 format:\n",
parsed$ref, call. = FALSE)
}
} else {
parsed$fo <- match.arg(fo, c("R1C1", "A1"))
}
parsed
}

Re: the cell ref specifically, parsed output should include ref and probably ul and lr. Examples:

ref = $B$2, ul and lr are either both $B$2 or both NA

ref = $B$2:$B$11, ul = $B$2, lr = $B$11

@jennybc jennybc changed the title Create an extractor for sheet Expose parsed ref string May 25, 2016
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