View source: R/csv_to_sql_db.R
csv_to_sql_db | R Documentation |
Reads FCC csv file in chunks while writing each chunk to a SQL
database before reading in the next chunk. DBI connection and FCC column
names from db_colname
function must be provided.
csv_to_sql_db(
csv_file,
con,
pre_process_size = 1000,
chunk_size = 50000,
show_progress_bar = TRUE,
db_colname
)
csv_file |
Name of raw FCC csv file to covert to SQL database. This is relative to the working directory unless an absolute file path is provided. |
con |
A DBIConnection object, as returned by |
pre_process_size |
Number of rows with which to initialize SQL db. |
chunk_size |
Number of rows to include for each chunk |
show_progress_bar |
Display progress bar? (default TRUE) |
db_colname |
Column names for FCC dataset, as returned by
|
Returns a SQLite database named "table_FCC" inside provided DBI connection
## Not run:
# set month and year of FCC data set to use
month = "December"
year = 2020
# download desired dataset
download_FCC(year, month)
# get proper column names
use_colnam <- get_colname(year, month)
# establish database connection
con <- DBI::dbConnect(SQLite(), dbname = "fcc.sqlite")
# filenames are constructed in the following format within `download_FCC`
filename <- paste0("FCC_fixed_brdbd_", month, "_", year, ".csv")
csv_to_sql_db(filename, con, db_colname = use_colnam)
# the SQL database created with `csv_to_sql_db` can be accessed in the
# following manner:
table <- tbl(con, "table_fcc")
# close the connection
dbDisconnect(con)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.