Friday, December 07, 2007

Extracting Door Data from .SIM Files Using Awk

Topic: Door counts, areas & conductance losses from SIM files using Awk data extraction scripts.

Below is a simple door counting script using GNU Awk. More sophisticated data extraction routines are in progress -- thanks to all the good people at comp.lang.awk:

# DOOR_COUNT.AWK extracts the door count from the specified .SIM report using
# GNU Awk for Windows:
#
# http://gnuwin32.sourceforge.net/packages/gawk.htm
#
# Note that GAWK.EXE must exist in the shell path. Thus after installation
# using the package installer, it is recommended that copies of GAWK.EXE,
# libconv2.dll, and libintl3.dll (found in
C:\Program Files\GnuWin32\bin in
# default installations)
be placed in the %WINDIR%\system32 directory.
#
#
Save this program as DOOR_COUNT.AWK in the eQuest projects directory, e.g.
#
# C:\Program Files\eQuest [Rev]\Projects\DOOR_COUNT.AWK
#
# ...where [Rev] is the current eQuest revision.
#
# If not done so already, under the "My Computer\System Properties\Advanced"
# tab click the "Environment Variables" button and add the following system
# environment variable:
#
# Variable name: AWKPATH
# Variable value: C:\Program Files\eQuest [Rev]\Projects
#
# ...where [Rev] is the current eQuest revision. This will allow AWK to find
# the program library from any project directory

#
# CMD-line usage:
#
# gawk -f DOOR_COUNT.AWK SimFile.SIM
#
# ...where the data file SimFile.SIM must exist in the current directory.
#

/TOTAL    WINDOWS/{go=1}/^[[:digit:][:space:]]+$/\
&&go{Doors+=$3;go=0}END{print "Door Count = " Doors}

No comments: