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

Build or identify function to burn out csv with "Site" and the alias_local_name , '.' pasteed to the start of the comments (ex. Site 1234_us.) #33

Open
Mateo9569 opened this issue May 9, 2023 · 3 comments

Comments

@Mateo9569
Copy link

The reason behind this is an issue with the alias_local_name column that involves inputting a 45 digit watershed code of a parent stream when no watershed code exists for a site. This would affect our scripts that manipulate data in this spreadsheet. Full issue is described in the skeena 2022 repo here.

@NewGraphEnvironment NewGraphEnvironment changed the title Build function to copy version of habitat_confirmations.xls to shared directory for submission Build or identify function to burn out csv with "Site" and the alias_local_name , '.' pasteed to the start of the comments (ex. Site 1234_us.) May 9, 2023
@NewGraphEnvironment
Copy link
Owner

use file.copy function to copy version of habitat_confirmations.xls to shared directory (and change filename) for submission first.

@Mateo9569
Copy link
Author

Here's some code I wrote to burn out csv with the info you mentioned pasted to start of comments column. It's not a function but I just wanted to show you this first.

target_dir <- paste0('data/inputs_extracted/hab_con_comments.csv')

file.copy(from = 'data/habitat_confirmations.xls',
          to = target_dir,
          overwrite = T)
hab_con <- fpr_import_hab_con(path = target_dir, 
                              col_filter_na = T, 
                              row_empty_remove = T, 
                              backup = FALSE) %>% 
  purrr::pluck("step_4_stream_site_data") %>% 
  mutate(comments = paste0('Site ', local_name, '. ', comments)) %>% 
  select(reference_number, gazetted_names, local_name, comments) %>% 
  write_csv(target_dir)

So after doing this, we should copy the original habitat_confirmations.xls to another directory, change the file name, update the alias_local_name if there's missing watershed codes, and also copy and paste the comments with the sites appended to the start. What directory should this file be put in? What should the file name be? The submission methods mention that the permit number should be in the file name. Let me know if I'm on the right track with all this.

@NewGraphEnvironment
Copy link
Owner

NewGraphEnvironment commented May 11, 2023

looks pretty good!

function would look like:

fpr_hab_alias_to_comments <- function(target = target_dir){
fpr_import_hab_con(path = target,
col_filter_na = T,
row_empty_remove = T,
backup = FALSE) %>%
purrr::pluck("step_4_stream_site_data") %>%
mutate(comments = paste0('Site ', local_name, '. ', comments)) %>%
select(reference_number, gazetted_names, local_name, comments) %>%
write_csv(target_dir)
}

then to run it is would just be:

fpr_hab_alias_to_comments() provided the target_dir object is defined.

You can customize with fpr_hab_alias_to_comments(target = 'different/path/from_the_other/this_csv.csv)

The file.copy call would be used again to burn a .xls file and it can be renamed at the same time according to the directions in the submission site which include the name of the permit. Same for the report actually (example: "NA16-21344_data.xls, NASU06-21344_report.pdf"). Report might be too big though so putting a link to the online one and the pdf one in the comments might be best. have a look at the old submissions.

Looks like skeena 2021 is already in there

You are prob on it already but I'd also change the name of hab_con in the actual script because it is used elsewhere in the repo for another needed object I believe.

The login is the NewGraph bceid and is the same as for the PSCIS data. Will likely change to Ltd. bceid for this years applications (vs submissions). Submissions to the NewGraph bceid

https://www2.gov.bc.ca/gov/content/environment/plants-animals-ecosystems/fish/fish-and-fish-habitat-data-information/fish-data-submission/submit-fish-data#submitfish

DFO permit number is XHAB 388 2022

image

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