digital-wellbeing / pws-data

Code used to process the raw PowerWash Simulator study dataset
Creative Commons Zero v1.0 Universal
4 stars 1 forks source link

export_table_to_csv by event_name? #1

Closed mvuorre closed 2 years ago

mvuorre commented 2 years ago

@rpsychologist the exported csv is becoming quite large to import / look at in R (which dummies like me need). Would it make sense / is it possible to e.g. export multiple CSVs by event_name?

rpsychologist commented 2 years ago

It would be easy to export to CSV by event_name, but it might be easier to just connect R to postgres

library(DBI)
con <- dbConnect(
    RPostgres::Postgres(),
    dbname = "postgres",
    host = "localhost",
    port = 5432,
    user = "postgres",
    password = "postgres"
)
DBI::dbListTables(con)
res <- dbSendQuery(con, "SELECT * FROM pws WHERE \"EventName\" = 'mood_reported'")
res <- dbFetch(res)
head(res)
mvuorre commented 2 years ago

This is a 5-star solution.