csv_to_sqlite: load csvs into database

View source: R/csv_to_sqlite.R

csv_to_sqliteR Documentation

load csvs into database

Description

point at a directory and load fusion derived tabular csv data into an sqlite database

Usage

csv_to_sqlite(
  db_path = "c:/temp/gridmetrics_compilation.sqlite",
  csv_folder,
  tb_summary = "gm_summary",
  tb_csv = "gm",
  project = "naip_2015",
  resolution = "66",
  units = "feet",
  proj4 = "",
  notes = "",
  skip_loaded = T,
  n_load = NA,
  use_col_classes = T,
  ncore = 4,
  dir_status = "c:\\temp\\csv_to_sqlite_status\\some_project\\"
)

Arguments

csv_folder

location of csv files

tb_summary

output name of summary table of csv files

tb_csv

table to dump csv files into

project

name of project

resolution

resolution of input data

units

unites of resolution

proj4

proj4 string of coordinate data

notes

any relevant notes

skip_loaded

should csv files which are already loaded be skipped

n_load

max number of files to load

use_col_classes

read colClasses from first file, and apply to remaining files - big read speedup

ncore

number of parallel threads to use at one time, ssds can handle many

dir_status

a way to report the status of the parallel threads, there is an output file for each input csv with at TRUE or FALSE in the name for write status

db

sqlite database connection

Details

<Delete and Replace>

This program is free software but it is provided WITHOUT WARRANTY and with ABSOLUTELY NO GUARANTEE of fitness or functionality for any purpose; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.


Revision History

1.0 1/18/2018 header added
1.1 1/21/2021 parallel writes enabled

Author(s)

Jacob Strunk <jacob.strunk@usda.gov>

See Also

run_gridmetrics
lasR_project

Examples

 library(lasR)
 dir_csv="I:\\projects\\2017_WA_DSM_Pilot\\2017Aug_NAIP\\gridmetrics1\\gridmetrics_csv\\"
   dir_sqlite="I:\\projects\\2017_WA_DSM_Pilot\\2017Aug_NAIP\\sqlite\\"
   dir.create(dir_sqlite)

   require(RSQLite)
   db <- dbConnect(SQLite(), dbname=file.path(dir_sqlite,"2015_NAIP_Metrics2.db"),sychronous = "off")


   csv_to_sqlite(db=db
                 ,csv_folder=dir_csv
   )


jstrunk001/RSForInvt documentation built on April 18, 2022, 11:03 p.m.