populate_template: Populate a GLIS template using the GLIS API

View source: R/populate_template.R

populate_templateR Documentation

Populate a GLIS template using the GLIS API

Description

This function accesses the API endpoints exposed by GLIS for the and populates an template data with the data for projects specified by the provided filter. By default, the output file is created in the current working directory, and is named dynamically from the values of the filter. Alternatively, the name of the target database can be provided by the user. Execution of the function will be stopped if the template cannot be found or the target (output) database already exists (unless overwrite=TRUE).

Usage

populate_template(
  filters,
  template_database,
  target = NULL,
  source = c("assessment", "creel"),
  overwrite = FALSE,
  prune_fn012 = FALSE,
  verbose = TRUE,
  verbose_sqlsave = FALSE
)

Arguments

filters

a named list of filters used to select the project(s) that will be inserted into the target database.

template_database

Character string. The path to the template database that will be copied and populated with data from GLIS.

target

The name of the target (output) database file. If no target is provide, a name will be built from the filter list.

source
  • string either 'assessment' or 'creel'

overwrite
  • Boolean. If a file with the same name as target, should it be overwritten?

prune_fn012
  • Boolean - should records in the FN012 table without any matching records in the FN123 (Catch counts) be deleted?

verbose
  • Boolean. Should progress be reported to the console?

verbose_sqlsave
  • Boolean. Default=FALSE. This value is passed through to RODBC::sqlsave. Set to True to see all of the sql statements passed to target database. Useful for debugging.

Details

NOTE this functionality is provided to facilitate updating, correcting and augmenting projects in GLIS. Changes made to the downloaded data should be uploaded back into GLIS as soon as possible. Downloaded data is not intended for long-term storage or subsequent data analysis. Data analysis and reporting should always be completed using data fetched directly from the API.

Author(s)

Arthur Bonsall arthur.bonsall@ontario.ca

Examples

## Not run: 
populate_template(
  list(prj_cd = "LEA_IA17_097"), "Great_Lakes_Assessment_Template_5.accdb"
)

populate_template(
  list(prj_cd = "LEA_IA23_SHA"), "Great_Lakes_Assessment_Template_5.accdb",
  "IBHN_2023_GLAT5.accdb"
)

populate_template(
  list(prj_cd = "LEA_IA22_093"), "Great_Lakes_Assessment_Template_5.accdb",
  "LPBTW_093_2023.accdb",
  prune_fn012 = TRUE
)

## End(Not run)

AdamCottrill/glfishr documentation built on Aug. 9, 2024, 5:47 p.m.