Description Usage Arguments Value Methods (by class) See Also Examples
download_civis
downloads a file based on the type of its first
argument, which can be a string "schema.table"
,
a SQL query sql(...)
, or a numeric file ID.
A table or a query from Redshift will be downloaded onto disk as a CSV. A file from Platform files endpoint will be downloaded as is.
A default database can be set using options(civis.default_db = "my_database")
.
If there is only one database available,
this database will automatically be used as the default.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 | download_civis(x, ...)
## S3 method for class 'character'
download_civis(
x,
database = NULL,
file,
overwrite = FALSE,
progress = FALSE,
split = FALSE,
job_name = NULL,
hidden = TRUE,
verbose = FALSE,
...
)
## S3 method for class 'sql'
download_civis(
x,
database = NULL,
file,
overwrite = FALSE,
progress = FALSE,
split = FALSE,
job_name = NULL,
hidden = TRUE,
verbose = FALSE,
...
)
## S3 method for class 'numeric'
download_civis(x, file, overwrite = FALSE, progress = FALSE, ...)
|
x |
|
... |
Currently ignored. |
database |
string, The database. If |
file |
string, The file to write to. |
overwrite |
logical, Whether to overwrite the existing |
progress |
logical, Whether to display a progress bar. |
split |
logical, Whether to download a big table by splitting it into multiple
CSV parts first. See |
job_name |
string, Name of the job (default: |
hidden |
logical, Whether the job is hidden on Platform. |
verbose |
logical, Whether to print detailed updates of job status. |
The file where the downloaded files or tables are written to. It is returned invisibly.
character
: Download a table from Redshift to disk as CSV.
sql
: Download the result of a SQL query from Redshift to disk as CSV.
numeric
: Download a file from Platform files endpoint to disk.
Other io:
query_civis_file()
,
query_civis()
,
read_civis()
,
write_civis_file()
,
write_civis()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | ## Not run:
# Download all columns in a single table into a CSV
download_civis("schema.table", database = "my_database",
file = "~/Downloads/my_table.csv")
# Download data from a SQL select statement into a CSV
query <- sql("SELECT * FROM table JOIN other_table USING id WHERE var1 < 23")
download_civis(query, database = "my_database",
file = "~/Downloads/my_table.csv")
# Set a default database
options(civis.default_db = "my_database")
# Download any file from the files endpoint.
file_id <- write_civis_file(df)
download_civis(file_id, file = "df.rds", progress = TRUE)
df2 <- readRDS("df.rds")
identical(df, df2)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.