download {basedosdados} | R Documentation |
Write the results of a query locally to a comma-separated file.
Description
Write the results of a query locally to a comma-separated file.
Usage
download(
query = NULL,
table = NULL,
path,
billing_project_id = get_billing_id(),
.na = " "
)
Arguments
query |
a string containing a valid SQL query. |
table |
defaults to |
path |
String with the output file's name. If running an R Project relative location can be provided. Passed to |
billing_project_id |
a string containing your billing project id. If you've run |
.na |
how should missing values be written in the resulting file? Value passed to |
Details
Currently there's only support for UTF-8 encoding. Users requiring more control over writing should use read_sql
to get the data in memory and custom code from there.
Value
Invisibly returns the query's output in a tibble. Intended to be used for side-effects. If you simply want to load a query's result in memory, use read_sql
.
Examples
## Not run:
path <- file.path(tempdir(), "pib_per_capita.csv")
bare_query <- "SELECT *
FROM basedosdados.br_tse_eleicoes.bens_candidato
WHERE ano = 2020
AND sigla_uf = \'TO\'"
download(query = bare_query, path = path)
# or download the entire table
download(table = "br_tse_eleicoes.bens_candidato", path = path)
## End(Not run)