Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Read CSV records from a file written by
#' read.serlog
#' Read CSV records from a file written by
#' @param file filename
#' @param varnames column names for the resulting \link{zoo} object
#' @export
read.serlog <- function(file, varnames) {
content <- gsub("\\t", ",", readLines(file))
columns <- c('datetime', 'millis', 'logger', 'loglevel', varnames)
records <- read.csv(textConnection(content), header=FALSE, stringsAsFactors=FALSE, col.names=columns)
timestamps <- with(records, paste(datetime, millis, sep='.'))
times <- as.POSIXct(strptime(timestamps, "%Y-%m-%d %H:%M:%OS"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment