Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

159
Vistas
export table to CSV in Redshift using R PostGreSQL

I connect to Redshift using R remotely from my workstation.

install.packages("RPostgreSQL") 
library (RPostgreSQL)

drv <- dbDriver("PostgreSQL")

con1 <- dbConnect(drv, host="url", port="xxxx", 
                  dbname="db_name", user="id", password="password") 

dbGetInfo(con1) 

then I create a table:

dbSendQuery(con1, "create table schema.table_name as select * from schema.table_name;")

now I want to export this table to a .csv file on my workstation, how to do this ? Again, I don't have PostGres database installed on my workstation, only using R to get to it.

Also, this table is LARGE, 4 columns, 14 million rows.

Thanks!

over 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

You'll need to pull down the results of a query into a local object, then dump the object to a CSV. Something along the lines of res <- dbSendQuery(con1, "select * from schema.table_name"); dat <-dbFetch(res); readr::write_csv(dat, "~/output.csv") should get you started.

over 4 years ago · Santiago Trujillo Denunciar

0

I figured this out after posting - sharing..

 system.time( fwrite(dbReadTable(con1, c("schema","table")), file="file.csv", sep=",", na="", row.names=FALSE, col.names=TRUE ))

I hear feather is even faster ?

this was for 43 million rows with 4 columns, took 15 minutes.

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda