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

Shiny app zip files with no folder name #109

Open
leppott opened this issue Jan 18, 2021 · 6 comments
Open

Shiny app zip files with no folder name #109

leppott opened this issue Jan 18, 2021 · 6 comments

Comments

@leppott
Copy link
Owner

leppott commented Jan 18, 2021

Is your feature request related to a problem? Please describe.
Zip files from Shiny app include "data" folder. Users confused that the files are part of the "data" process.

Describe the solution you'd like
Removed the "data" folder from the zip files generated by the Shiny app.

Describe alternatives you've considered
Using other folder name too messy for the Shiny app.

Additional context
Possibly use zip::zip() instead of utils::zip()

@leppott
Copy link
Owner Author

leppott commented Jan 18, 2021

Solution is not zip::zip() but to use "extras = "-j"" to strip the path.

https://stackoverflow.com/questions/50339737/cannot-zip-directory-from-within-r-without-including-full-file-path

@leppott
Copy link
Owner Author

leppott commented Jan 18, 2021

Five ways to get a zip file so have to ensure each has the modified code.

  • QC
  • Aggregate
  • SummaryStats
  • Hobo
  • Gage

@leppott
Copy link
Owner Author

leppott commented Jan 18, 2021

Works in console but when run in Shiny it fails to create the zip file.

image

@leppott
Copy link
Owner Author

leppott commented Jan 18, 2021

put on hold

@leppott
Copy link
Owner Author

leppott commented Feb 8, 2021

https://stackoverflow.com/questions/51770621/zip-files-without-directory-name-in-r

Tested "-j" and it worked.

# Examples of each operation

# 00. Set up
# Parameters
Selection.Operation <- c("GetGageData"
                         , "QCRaw"
                         , "Aggregate"
                         , "SummaryStats")
Selection.Type      <- c("Air","Water","AW","Gage","AWG","AG","WG")
Selection.SUB <- c("Data0_Original"
                   , "Data1_RAW"
                   , "Data2_QC"
                   , "Data3_Aggregated"
                   , "Data4_Stats")
(myDir.BASE <- tempdir()) # create and print temp directory for example data

# Create data directories
myDir.create <- file.path(myDir.BASE, Selection.SUB[1])
  ifelse(dir.exists(myDir.create) == FALSE
         , dir.create(myDir.create)
         , "Directory already exists")
myDir.create <- file.path(myDir.BASE, Selection.SUB[2])
  ifelse(dir.exists(myDir.create) == FALSE
         , dir.create(myDir.create)
         , "Directory already exists")
myDir.create <- file.path(myDir.BASE, Selection.SUB[3])
  ifelse(dir.exists(myDir.create) == FALSE
         , dir.create(myDir.create)
         , "Directory already exists")
myDir.create <- file.path(myDir.BASE, Selection.SUB[4])
  ifelse(dir.exists(myDir.create) == FALSE
         , dir.create(myDir.create)
         , "Directory already exists")
myDir.create <- file.path(myDir.BASE, Selection.SUB[5])
  ifelse(dir.exists(myDir.create) == FALSE
         , dir.create(myDir.create)
         , "Directory already exists")

# Save example data (assumes myDir.BASE directory exists)
myData <- data_raw_test2_AW_20130426_20130725
  write.csv(myData, file.path(myDir.BASE
                              , Selection.SUB[2]
                              , "test2_AW_20130426_20130725.csv"))
myData <- data_raw_test2_AW_20130725_20131015
  write.csv(myData, file.path(myDir.BASE
                              , Selection.SUB[2]
                              , "test2_AW_20130725_20131015.csv"))
myData <- data_raw_test2_AW_20140901_20140930
  write.csv(myData, file.path(myDir.BASE
                              , Selection.SUB[2]
                              , "test2_AW_20140901_20140930.csv"))
myData <- data_raw_test4_AW_20160418_20160726
  write.csv(myData, file.path(myDir.BASE
                              , Selection.SUB[2]
                              , "test4_AW_20160418_20160726.csv"))
myFile <- "config.TZ.Central.R"
  file.copy(file.path(path.package("ContDataQC"), "extdata", myFile)
            , file.path(myDir.BASE, Selection.SUB[2], myFile))

# zip file
setwd(tempdir())
zip("test_nodir.zip", list.files("Data1_RAW", pattern = "*.csv", full.names = TRUE), "-j")

image

leppott added a commit that referenced this issue Feb 23, 2021
* refactor: Shiny server, zip files add -j to strip folder names, Issue #109
* refactor: Add additional DO parameters to config, Issue #117
* refactor: Update other versions of config, Issue #117
* docs: Update README install directions
* docs: README, trim lines to 80 characters
* docs: Move planned updates from NEWS to README
* refactor: Update Report_Config.rmd for new DO parameters, Issue #117
* refactor: Update Report_Config.rmd so sensor depth and water level are next
to each other
* refactor: Copy updated Report_Config.rmd to Shiny app, Issue #117
* refactor: Add additional DO parameters (n=3) to reformatHobo function
, Issue #117
@leppott
Copy link
Owner Author

leppott commented Feb 24, 2021

Did not work in practice.

Had added full.names as a parameter. It was causing issues. Removed it.

leppott added a commit that referenced this issue Feb 24, 2021
* feature: Shiny formatHobo add inputselect for date format, Issue #117
* refactor: Shiny server.R remove full.names from zip routine preventing
proper construction of download zip file, Issue #109
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant