if (FALSE) {
# Read all columns in a single table
df <- read_civis("schema.my_table", database = "my_database")
# Read data from a SQL select statement
query <- sql("SELECT * FROM table JOIN other_table USING id WHERE var1 < 23")
df <- read_civis(query, database = "my_database")
# Read an R object from the files endpoint.
id <- write_civis_file(df)
df <- read_civis(id)
# Read a text file or csv from the files endpoint.
id <- write_civis_file("my_csv.csv")
df <- read_civis(id)
# Read JSONValues from a civis script
vals <- read_civis(civis_script(1234))
# Read File run outputs from a civis script
df <- read_civis(civis_script(1234), regex = '.csv', using = read.csv)
obj <- read_civis(civis_script(1234), regex = '.rds', using = readRDS)
# Gracefully handle when read_civis.sql returns no rows
query <- sql("SELECT * FROM table WHERE 1 = 2")
mean_x <- tryCatch({
df <- read_civis(query, database = "my_database")
mean(df$x)
}, empty_result_error = function(e) {
NA
})
}
Run the code above in your browser using DataLab