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

use system unzip if colon in title #345 #329 (draft) #348

Closed
wants to merge 1 commit into from

Conversation

WillForan
Copy link

fetch_survey:export_responses_filedownload can use external unzip binary This streams zip file contents into a temporary csv file to avoid unz()

TODO: check system('which unzip') or error?

fetch_survey:export_responses_filedownload can use external unzip binary
This streams zip file contents into a temporary csv file to avoid unz()

TODO: check system('which unzip') or error?
@juliasilge
Copy link
Collaborator

This unfortunately is not going to work on Windows AFAIK, so we do need to find a solution for #345, #329, and friends that does not rely on a system() call. 😕

Thank you so much for your interest in contributing, though!

@WillForan
Copy link
Author

it looks like windows includes tar.exe which can unzip .zip to stdout. I think that looks like tar.exe -Oxf zipfile.zip. Though I'm not sure what file redirect looks like with R's system() on windows. maybe unizip -p survey.zip > tmp could be tar -Oxf survey.zip > tmp when grepl("windows", .Platform$OS.type)? If this kludge is even worth pursuing

@WillForan
Copy link
Author

alternatively, instead of creating a temp file, maybe the tar.exe/unzip to stdin could be captured with pipe()?

quick test on linux looks promissing

> system("echo 'a,b,c' > test.csv; zip test.zip test.csv")
  adding: test.csv (stored 0%)
> read.csv(pipe('unzip -p test.zip'),header=F)
  V1 V2 V3
1  a  b  c

@juliasilge
Copy link
Collaborator

Thank you so much for your thoughts @WillForan! I don't know that using a system() call is a very robust way to go in general, but I did open up #349 that uses the archive package instead of unz() from base R, because it has better file path handling. I think between using archive and fs, we may have solved the problem.

Want to take it for a spin, with devtools::install_github("ropensci/qualtRics@use-archive-extract")?

@WillForan
Copy link
Author

Thanks! Works for me! I just needed an extra apt install libarchive-dev -- and install.packages('archive')'s failure had a useful message instructing me to do so.

Closing this PR

@WillForan WillForan closed this Jul 31, 2024
@juliasilge
Copy link
Collaborator

That is great news! Thank you for trying it out @WillForan. 🙏

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

Successfully merging this pull request may close these issues.

2 participants