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

split_pdf on Windows PC #14

Open
pohndorff opened this issue Jun 19, 2018 · 6 comments
Open

split_pdf on Windows PC #14

pohndorff opened this issue Jun 19, 2018 · 6 comments
Labels
failed to replicate Failed to replicate the issue. Might need additional details to isolate the problem

Comments

@pohndorff
Copy link

I have an issue migrating my code from MacOS to Windows devices.
The following code snippet works just fine on my MacOS but hangs itself after the first iteration:

include
path <- list.files(path = paste0(getwd(),"/raw"),
                   pattern = "*.pdf",
                   recursive = TRUE,
                   full.names =  TRUE)
file <- list.files(path = paste0(getwd(),"/raw"),
                   pattern = "*.pdf",
                   recursive = TRUE)

for(i in 1:length(file)){
  file.path <- str_extract(file[i],".*(?=(KV[0-9]+\\.pdf))")
  dir.create(file.path(paste0(getwd(),"/output/",file.path)), showWarnings = FALSE)
  split_pdf(input_filepath = path[i],
            output_directory = file.path,
            prefix = paste0("p","_"))
}

I installed pdftk on both devices and they work fine, so I guess it's an issue regarding staplr.

Any suggestions to quickly solve the issue?

@oganm
Copy link
Collaborator

oganm commented Jun 19, 2018

Probably related to slash directions on the filepath

@pohndorff
Copy link
Author

Yeah, stupid me 🤦‍♂️
Can be closed now.

@oganm
Copy link
Collaborator

oganm commented Jun 19, 2018

no no. it's our fault if R/unix style slashes break things on windows. I just wrote it as the potential issue to return for a fix later

@oganm oganm reopened this Jun 19, 2018
@oganm oganm assigned oganm and unassigned oganm Jun 23, 2018
@oganm
Copy link
Collaborator

oganm commented Jun 28, 2018

About it hanging itself, does it happen on the mac? See #7 if it does.

About the slash issue, were you actually able to fix it by changing slash directions? Because I can't replicate the issue on my windows

@pohndorff
Copy link
Author

The infinite loop only occurred on Windows so far.

Regarding the solution: I used the file.path() function on it so it autocorrected on any OS. My misconception was due to lacking documentation. I’d suggest to describe to attribute types more precisely. For this take reference to Hadley Wickhams book on R packages http://r-pkgs.had.co.nz/man.html#man-functions

@oganm
Copy link
Collaborator

oganm commented Jun 28, 2018

Could you give me the path that failed. Because based on my experimentation in windows, it works with any combination of \s and /s.

I tried to replicate your code by making some assumptions about your file structure. I placed a pdf at the path raw/dir/KV111.pdf

Based on this structure your code doesn't and shouldn't work regardless of the OS as it is trying to place the output at dir directory which doesn't exist because the directory it created is actually called output/dir (assuming output directory already exists as recursive = FALSE in dir.create). I imagine some pieces were lost during the copy paste process here but it's making it hard for me to understand what exactly didn't work in the first place.

If I understand what went wrong to begin with I can see if some explanation could be added to the docs

@oganm oganm added the failed to replicate Failed to replicate the issue. Might need additional details to isolate the problem label Nov 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
failed to replicate Failed to replicate the issue. Might need additional details to isolate the problem
Projects
None yet
Development

No branches or pull requests

2 participants