export_xls: Export LTVMP data to database

View source: R/export_xls.R

export_xlsR Documentation

Export LTVMP data to database

Description

This function uses import_xls to read the Excel workbooks into R, then exports the components returned by import_xls to tables in the SEUG LTVMP database.

Usage

export_xls(
  my_xls,
  my_db,
  data_table,
  sampling_event_table,
  import_table,
  verbose = TRUE,
  view = TRUE
)

Arguments

my_xls

A character string of the complete file path of the *.xls file.

my_db

A connected database from RODBC.

data_table

A character string of the name of the frequency and cover data table.

sampling_event_table

A character string of the name of the sampling event table.

import_table

A character string of the name of the import log.

verbose

Optional. Prints messages to the console showing function progress. Default is TRUE. If FALSE, messages are suppressed.

view

Optional. Prints data to console before writing them to the database. Default is TRUE. If FALSE, data are not printed and there is no prompt before writing data to the database.

Details

This function uses import_xls to import LTVMP data into R and then export it to a connected Microsoft Access database.

Value

Data is written to database tables. Objects are not returned.

See Also

import_xls, RODBC, sqlSave, odbcConnectAccess2007

Examples

## Not run: 
library("dataprocessR")

# Connect to DB
my_db <- RODBC::odbcConnectAccess2007("C:/path/to/database.accdb")

# List files
my_dir <- "C:/path/to/data"
file_list <- list.files(my_dir, pattern = ".xls", full.names = TRUE,
                        recursive = FALSE)

# Process file and save to database
export_xls(my_xls = file_list[1], my_db = my_db,
           data_table = "tblData_FreqCov",
           sampling_event_table = "tblSamplingEvent",
           import_table = "tblImportRecord")

## End(Not run)

scoyoc/dataprocessR documentation built on March 11, 2023, 6:02 a.m.