Skip to content

Instantly share code, notes, and snippets.

@mgtagle
Forked from brews/fire_stacker.R
Created October 6, 2015 20:03
Show Gist options
  • Save mgtagle/1585d033047d2ea04c5e to your computer and use it in GitHub Desktop.
Save mgtagle/1585d033047d2ea04c5e to your computer and use it in GitHub Desktop.
Combine multiple FHX files for Ellis.
#! /usr/bin/env Rscript
# 2015-02-25 S. B. Malevich
# Combine all FHX files in the current working directory and try to output it
# as a single FHX file (`OUTFILE`). You need to have "firehistory.R" in the
# same directory, too.
ARGS <- commandArgs(TRUE)
source("firehistory.R")
OUTFILE <- "bigfile.fhx"
targets <- Sys.glob("*.fhx")
blob.fhx <- read.fhx(targets[1])
stopifnot(length(targets) >= 2) # In case only 1 FHX file in directory.
for (i in seq(2, length(targets))) {
t <- targets[i]
print(paste(Sys.time(), "Working on file:", t)) # DEBUG
victim.fhx <- read.fhx(t)
blob.fhx <- blob.fhx + victim.fhx
}
write.fhx(blob.fhx, fname = OUTFILE)
q(status = 0, save = 'no')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment