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

special characters in file path #82

Open
py-b opened this issue May 21, 2022 · 3 comments
Open

special characters in file path #82

py-b opened this issue May 21, 2022 · 3 comments

Comments

@py-b
Copy link

py-b commented May 21, 2022

Hello,

xlsx_cells is not able to read a file when there are special characters (as "é" in french) in its path.

Here is a reproducible example :

library(tidyxl)

examples <- system.file("extdata/examples.xlsx", package = "tidyxl")

path_with_special_char <- file.path(tempdir(), "é")
dir.create(path_with_special_char)
file.copy(examples, path_with_special_char)

xlsx_cells(file.path(path_with_special_char, "examples.xlsx"))
# Error in xlsx_sheet_files_(path) :
#   Evaluation error: zip file 'C:/Users/XKFZV/AppData/Local/Temp/RtmpU1yg8b/é/examples.xlsx' cannot be opened.

I run this on Window. My sessionInfo :

R version 4.0.5 (2021-03-31)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows Server x64 (build 17763)

Matrix products: default

locale:
[1] LC_COLLATE=French_France.1252  LC_CTYPE=French_France.1252    LC_MONETARY=French_France.1252
[4] LC_NUMERIC=C                   LC_TIME=French_France.1252

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
[1] tidyxl_1.0.7

loaded via a namespace (and not attached):
[1] compiler_4.0.5 tools_4.0.5    Rcpp_1.0.8     tcltk_4.0.5
@nacnudus
Copy link
Owner

I can't reproduce this error on my Linux device, or in Windows via GitHub Actions. The code that unzips the file is in https://github.com/nacnudus/tidyxl/blob/main/R/zip.R. Please could you try running similar code, to see where the error happens?

@py-b
Copy link
Author

py-b commented Jun 18, 2022

Unzipping the file with your code works fine. So the problem seems to be elsewhere.

I debugged a bit and found out the error mesage occurs in check_sheets, more precisely in xlsx_sheet_files_. Unfortunately, I have not been able to dig further, as I my knowledge on C++ is very limited.

Also note the code of my first message ran successfully on another computer of mine which is Windows too...

@py-b
Copy link
Author

py-b commented Jul 9, 2024

Hello again. I'm not giving up on this one. 😉

I think I managed to make the problem reproducible. Apparently the bug happens when the paht is encoded in UTF-8.

Here is the updated MRE :

library(tidyxl)

examples <- system.file("extdata/examples.xlsx", package = "tidyxl")

path_with_special_char <- file.path(tempdir(), "é")

# update here : convert to UTF-8
path_with_special_char <- iconv(path_with_special_char, "latin1", "UTF-8")

dir.create(path_with_special_char)
file.copy(examples, path_with_special_char)

xlsx_cells(file.path(path_with_special_char, "examples.xlsx"))

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

2 participants