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

xls path containing the "~" shortcut can't be read #498

Closed
ddheart opened this Issue Aug 20, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@ddheart
Copy link

ddheart commented Aug 20, 2018

Minor issue: the '~' character on macOS used to point to the home folder causes readxl to throw an error.

library(readxl)
(xl <- read_excel('/Users/mbpro/codingprojects/tests/Book1.xls'))
#> New names:
#> abc -> abc..1
#> abc -> abc..2
#> # A tibble: 4 x 2
#>   abc..1 abc..2
#>    <dbl>  <dbl>
#> 1      4      2
#> 2      3      3
#> 3      7      5
#> 4      2      2
dput(xl)
#> structure(list(abc..1 = c(4, 3, 7, 2), abc..2 = c(2, 3, 5, 2)), row.names = c(NA, 
#> -4L), class = c("tbl_df", "tbl", "data.frame"))
read_excel('~/codingprojects/tests/Book1.xls')
#> Error in read_fun(path = enc2native(path), sheet_i = sheet, limits = limits, : Failed to open ~/codingprojects/tests/Book1.xls
@jennybc

This comment has been minimized.

Copy link
Member

jennybc commented Aug 20, 2018

Hmm ... a workaround in the meantime is:

read_excel(normalizePath("~/path/to/your.xls"))

@jennybc jennybc added the bug label Aug 20, 2018

@jennybc

This comment has been minimized.

Copy link
Member

jennybc commented Aug 20, 2018

I believe we have just rediscovered a good reason why xls paths were being normalized:

#477 (comment)

@jennybc jennybc added the xls 👵 label Aug 20, 2018

@jennybc jennybc changed the title "~" Tilde pathname shortcut crashes read_excel xls path containing the "~" shortcut can't be read Aug 20, 2018

jennybc added a commit that referenced this issue Aug 20, 2018

Normalize all paths, prior conversion to native encoding
Fixes #498

Prior to b10a1a8,all xls paths were normalized, but we didn't know exactly why. In b10a1a8, I stopped normalizing xls paths, while solving an unrelated path encoding problem presented by R 3.5.

In discussion around #477, @jimhester said:

"I think doing enc2native(normalizePath()) on the R side for both xls and xlsx seems the best option."

I am now taking this wise advice.

@jennybc jennybc closed this in #499 Aug 21, 2018

jennybc added a commit that referenced this issue Aug 21, 2018

Normalize all paths, prior conversion to native encoding (#499)
Fixes #498

Prior to b10a1a8,all xls paths were normalized, but we didn't know exactly why. In b10a1a8, I stopped normalizing xls paths, while solving an unrelated path encoding problem presented by R 3.5.

In discussion around #477, @jimhester said:

"I think doing enc2native(normalizePath()) on the R side for both xls and xlsx seems the best option."

I am now taking this wise advice.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment