Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

anonymize db files #1

Open
tobiasgerstenberg opened this issue Oct 4, 2018 · 0 comments
Open

anonymize db files #1

tobiasgerstenberg opened this issue Oct 4, 2018 · 0 comments

Comments

@tobiasgerstenberg
Copy link
Collaborator

worker ids need to be removed before making a project public.

  1. remove the current participant.db files from the repo see here

  2. save script below as anonymize_participants_db.R in the same folder as the participants.db file you want to anonymize

# Load packages -------------------------------------------------------------------------------
library(RSQLite)
library(tidyverse)

# Handle input --------------------------------------------------------------------------------
args = commandArgs(T)

filename = args[1]
tablename = args[2]

# Anonymize table -----------------------------------------------------------------------------
con = dbConnect(SQLite(),dbname = paste0(filename));
df.table = dbReadTable(con,tablename)
dbDisconnect(con)

df.table = df.table %>%
	mutate(datastring = str_replace_all(datastring,uniqueid,as.character(row_number())),
				 datastring = str_replace_all(datastring,workerid,as.character(row_number()))) %>%
	select(-uniqueid,-workerid,-ipaddress)

con = dbConnect(SQLite(), paste0(str_remove(filename,".db"),"_anonymized.db"))
dbWriteTable(con,tablename,df.table)
dbDisconnect(con)
  1. run in terminal using:
Rscript anonymize_participants_db.R filename tablename
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant