Skip to content

Instantly share code, notes, and snippets.

@myazdani
Last active August 29, 2015 13:58
Show Gist options
  • Save myazdani/10411621 to your computer and use it in GitHub Desktop.
Save myazdani/10411621 to your computer and use it in GitHub Desktop.
used to merge a meta data CSV (generated from SQL) with QTIP measurements CSV.
options = commandArgs(trailingOnly = TRUE)
file1 = options[1] #QTIP file
file2 = options[2] #SQL query file
field_name = options[3] #not used - replace with what column name to use
outpath = options[4] #name of output file
file1.df = read.csv(file1, header = TRUE, stringsAsFactors = FALSE)
file2.df = read.csv(file2, header = TRUE, stringsAsFactors = FALSE)
get.filename = function(x) {
splitted = strsplit(x, split = "/")[[1]]
return(splitted[length(splitted)])
}
file1.df = file1.df[-1,]
file1.df$filename = sapply(file1.df$filename, get.filename)
file2.df$filename = sapply(file2.df$full_path, get.filename)
features.query = merge(file1.df, file2.df, by = "filename")
write.csv(features.query, file = outpath, row.names = FALSE, quote = FALSE)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment