List Info

Thread: GAWK Support




GAWK Support
user name
2006-06-30 10:22:57
To comment on the following update, log in, then open the
issue:
http://www.openoffice.org/issues/show_bug.cgi?id=66816





------- Additional comments from discoleoopenoffice.org Fri Jun 30 03:22:57 -0700 2006 -------
EXAMPLE OF GAWK USE

Here is a real-life example showing the usefulness of
gawk/awk:

I worked recently on a patient DB and wanted to create some
dummy variables for
the hospital unit (patient category).

GAWK SCRIPT
($1 contains the input - the hospital unit)
$2 = 0 # neurosurgery vs non-neurosurgery
$3 = 0 # neurology vs non-neurology
$4 = 0 # general surgery vs non-surgery
$5 = 0 # internal maedicine vs non-im
$6 = 1 # ERROR var, if unknown abreviation

$0 = tolower($0)

# NEUROSURGERY
/nch/ {$2 = 1, $6 = 0 }

# Neurology
/^n$|^ne/ {$3 = 1, $6 =0 }

# General Surgery
/^ch/ {$4 = 1, $6 =0 }

# INTERNAL MEDICINE
/mi|end|nut/ {$5 = 1, $6 =0 }

print $0 >> 'out-file'

### END SCRIPT

 - this simple script does exactly what I wanted in a very
simple fashion,
AND
 - it took me less than 5 minutes to write it!!!

The execution is almost instantly even on big files (~1 MB
text file).

Unfortunately, I didn't manage to get this same thing done
using only Calc's
functionality. (One reason is the problem with the find()
function described
previously; this severe limitation of Calc hampers any
serious work with strings.)

------------------------------------------------------------
---------
Please do not reply to this automatically generated
notification from
Issue Tracker. Please log onto the website and enter your
comments.
http://qa.openoffice.org/issue_handling/
project_issues.html#notification

------------------------------------------------------------
---------
To unsubscribe, e-mail: issues-unsubscribesc.openoffice.org
For additional commands, e-mail: issues-helpsc.openoffice.org

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )