NewGraphEnvironment / fpr

Fish Passage Reporting functions for British Columbia
http://www.newgraphenvironment.com/fpr/
Other
2 stars 2 forks source link

`fpr_import_pscis` failing with empty spreadsheet. #63

Closed lucy-schick closed 5 months ago

lucy-schick commented 5 months ago

Issue: fpr_import_pscis is used in the Skeena 2023 and Fraser 2023 repo to import the pscis_phase1.xlsmspreadsheet as a template, but I am running into errors when the pscis_phase1.xlsm is empty, because of the lubridate::ymd_hms() call with an empty date and time.

Reprex: Need to ensure pscis_phase1.xlsm is empty before running this, current pscis_phase1.xlsm in skeena repo contains data.

library(tidyverse)

template <- fpr::fpr_import_pscis() %>%
  slice(0)
#Warning message:                                                                                                                   
There was 1 warning in `dplyr::mutate()`.
ℹ In argument: `date_time_start = lubridate::ymd_hms(paste0(date, " ", time_start))`.
Caused by warning:
! All formats failed to parse. No formats found. 

Created on 2024-03-26 with reprex v2.1.0

location: I think this is where it is failing, https://github.com/NewGraphEnvironment/fpr/blob/main/R/import.R#L86C7-L86C75. Because since pscis_phase1.xlsm is empty, data and time_start are both empty, so lubridate::ymd_hms() can't format properly and throws an error.

What I've tried:

NewGraphEnvironment commented 5 months ago

this is a workflow change issue addressed here

https://github.com/NewGraphEnvironment/fish_passage_fraser_2023_reporting/blob/main/scripts/05_pscis_export_submission.R

we used to populate the spreadsheet first then add details within it. now we try to do it all in Q first. for this reason there is no data in the spreadsheet at the point where we export... fpr::fpr_xref_template_pscis() was developed to deal with this

NewGraphEnvironment commented 5 months ago

fpr::fpr_xref_template_pscis() can be used as a template

fpr_import_pscis shouldl still be good to go for importing the actual data

lucy-schick commented 5 months ago

okay thanks