Wednesday, November 07, 2007

eQuest SIM File Data Extraction Using Awk

Topic: Extracting discrete data values using Gawk (GNU Awk)

Following are some (one, for now) potentially useful Gawk (using GNU Awk for Win32) scripts for extracting data from an eQuest/DOE2 output SIM file :

# Save this script to a file named BEPU.AWK in the directory
# containing the simulation output files.
#
# BEPU.AWK extracts energy consumption totals 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 a copy of GAWK.EXE
# be placed in the %WINDIR%\system32 directory.
#
# Usage:
#
# gawk -f BEPU.AWK SimFile.SIM
#
# ...where the program file BEPU.AWK and data file SimFile.SIM must exist.
#

{if ($2 ~/BEPU/) {ipr = 1}}
{if (ipr == 1)
{if ($1 == "TOTAL") print $1" "$2" "$3" "$4
if ($2 == "PS-H") ipr = 0}}
At left is a simple Awk script to extract the energy consumption totals in kWH and therms from the specified SIM file.

Run this script from a CMD prompt in the same directory as your .SIM files; be sure to copy GAWK.EXE to %WINDIR%\System32, where %WINDIR% is usually (but not always) C:\WINDOWS.

Modified from an original script posted by Joe Huang in the BLDG-SIM archives.

Thanks Joe!

More fun with Awk and SED to come over the next few months, as time permits or workload demands.

Note that in this example, printing is turned on (ipr = 1) by flagging the desired report, and off (ipr = 0) by flagging the report following the desired report. Examine the contents of the SIM file or see this post to determine the actual report sequence -- its not the same as shown in the drop-down box in the SIM file viewer.

More Awk examples from elsewhere...

3 comments:

atlas245 said...

I thought the post made some good points on extracting data, I use python for simple extracting data,data extraction can be a time consuming process but for larger projects like the web, files, or documents i tried http://www.extractingdata.com which worked great, they build quick custom screen scrapers, extracting data, and data parsing programs

Eva Joseph said...

I have read your post . It was very interesting and useful one.Keep in blogging.If you need any services like Data Science & Machine learning | data extraction solutions | Digital payment integration | Create Ecommerce website

yathish said...

I have read your blog. Great information that you were shared in a good way.Digital Payment Platform|
Digital payment integration