From f36a7052b38ad8ca4f039ffdcfc1b49ec551d449 Mon Sep 17 00:00:00 2001 From: JulioV Date: Wed, 28 Oct 2020 14:11:41 -0400 Subject: [PATCH] Add config update file to create participants file --- config.yaml | 2 +- src/data/create_participants_files.R | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/config.yaml b/config.yaml index 7b07564c..d82fcffa 100644 --- a/config.yaml +++ b/config.yaml @@ -15,7 +15,7 @@ CREATE_PARTICIPANT_FILES: TYPE: AWARE_DEVICE_TABLE #AWARE_DEVICE_TABLE or CSV_FILE DATABASE_GROUP: *database_group CSV_FILE_PATH: "data/external/example_participants.csv" # must have columns: PHONE DEVICE_ID_COLUMN, FITBIT DEVICE_ID_COLUMN, pid , label, start_date, end_date - TIMEZONE: *timezone # only used for AWARE_DEVICE_TABLE + TIMEZONE: *timezone PHONE_SECTION: ADD: TRUE DEVICE_ID_COLUMN: device_id # column name diff --git a/src/data/create_participants_files.R b/src/data/create_participants_files.R index b36b9cde..a26f163c 100644 --- a/src/data/create_participants_files.R +++ b/src/data/create_participants_files.R @@ -70,4 +70,12 @@ participants %>% writeLines(lines, file_connection) close(file_connection) - }, add_phone_section, add_fitbit_section, phone_device_id_column, fitbit_device_id_column) \ No newline at end of file + }, add_phone_section, add_fitbit_section, phone_device_id_column, fitbit_device_id_column) + +file_lines <-readLines("./config.yaml") +for (i in 1:length(file_lines)){ + if(startsWith(file_lines[i], "PIDS:")){ + file_lines[i] <- paste0("PIDS: [", paste(participants$pid, collapse = ", "), "]") + } +} +writeLines(file_lines, con = "./config.yaml") \ No newline at end of file