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

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

Closed
lgtm70b opened this issue Aug 20, 2018 · 2 comments
Closed

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

lgtm70b opened this issue Aug 20, 2018 · 2 comments
Labels
bug an unexpected problem or unintended behavior xls 👵

Comments

@lgtm70b
Copy link

lgtm70b 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
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 an unexpected problem or unintended behavior label Aug 20, 2018
@jennybc
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 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
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 added a commit that referenced this issue Aug 21, 2018
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.
@lock lock bot locked and limited conversation to collaborators Oct 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug an unexpected problem or unintended behavior xls 👵
Projects
None yet
Development

No branches or pull requests

2 participants