print(paste0("Looking for files matching ",pattern," in ",fpath))
dt<-as.data.table(list.files(path=fpath,pattern=pattern,# use the pattern to filter e.g. 1m from 30s files
recursive=TRUE))
print("First 6 rows of list:")
print(head(dt))
print("Processing file list")
dt<-dt[,
c("hhID","fileName"):=tstrsplit(V1,"/")# get actual household id & filename
]
dt<-dt[,
fullPath:=paste0(fpath,"/",V1)# get full path
]
print(paste0("Found ",tidyNum(nrow(dt))," files from ",uniqueN(dt$hhID)," households."))
return(dt[,.(hhID,fullPath)])
return(dt)
}
#' Load all available 1 minute grid spy data files from the list returned by list1mGridSpyFiles
#'
#' \code{process1mGridSpyFiles}. Loads, processes ans saves 1 minute grid spy files by iterating over each household id. We we cannot just concatinate all the files since the
#' column headings (circuit labels) vary. The function saves out 1 data file per household ID per month as a gzipped .csv file.
#' @param dt a data table with 2 columns: hhID and fullPath derived from list1mGridSpyFiles()
#'
#' @author Ben Anderson, \email{b.anderson@@soton.ac.uk}