[PLUG] awk: next statement not working as intended

Rich Shepard rshepard at appl-ecosys.com
Mon Jul 2 23:41:32 UTC 2012


On Mon, 2 Jul 2012, Larry Brigman wrote:

> A larger data set and a larger section of the script will be needed as the
> script won't print anything as written.

Larry,

   Here's the script:

#! /usr/bin/gawk -f

BEGIN { FS = "|"; OFS = "|" }

# If no quantity, drop row
$4 ~ /""/ { next; }

# If date prior to 2007, date code = 0
$2 < /"2007-01-01"/ { print $1, $2, 0, $3, $4, $5, $6, $7 }

# If date since 2007, date code = 1
$2 > /"2006-12-31"/ { print $1, $2, 1, $3, $4, $5, $6, $7 }

   And here are some data:

'D-1'|'2007-12-12'|'Ag'|0.005|1|0|0.005
'D-1'|'2007-12-12'|'Al'|0.106|0|0.106|0.106
'D-1'|'2007-12-12'|'CO3'|1|1|0|1
'D-1'|'2007-12-12'|'HCO3'|231.000|0|231.000|231.000
'D-1'|'2007-12-12'|'Alk_tot'|231.000|0|231.000|231.000
'D-1'|'2007-12-12'|'Bi'|0.001|1|0|0.001
'D-1'|'2007-12-12'|'Ca'|100.000|0|100.000|100.000
'D-1'|'2007-12-12'|'Cl'|1.430|0|1.430|1.430
'D-1'|'2007-12-12'|'Cr'|0.006|1|0|0.006
'D-1'|'2007-12-12'|'Cu'|0.024|0|0.024|0.024
'D-1'|'2007-12-12'|'DO'|4.960|0|4.960|4.960
'D-1'|'2007-12-12'|'Fe'|4.110|0|4.110|4.110
'D-1'|'2007-12-12'|'Hg'||0||
'D-2'|'2009-10-05'|'oil_grease'||0||
'D-2'|'2009-10-05'|'Pb'|0.025|0|0.025|0.025
'D-2'|'2009-10-05'|'pH'|7.690|0|7.690|7.690
'D-2'|'2009-10-05'|'Sb'|0.001|1|0|0.001
'D-2'|'2009-10-05'|'SC'|471.000|0|471.000|471.000
'GW-2'|'1992-02-29'|'Al'|0.001|1|0|0.001
'GW-2'|'1992-02-29'|'CO3'||0||
'GW-2'|'1992-02-29'|'HCO3'||0||
'GW-2'|'1992-02-29'|'Alk_tot'||0||
'GW-2'|'1992-02-29'|'As'|0.001|1|0|0.001
'GW-2'|'1992-02-29'|'Cr'|0.03|1|0|0.03
'GW-2'|'1992-02-29'|'Cu'|0.001|1|0|0.001
'GW-2'|'1992-02-29'|'DO'||0||

Rich




More information about the PLUG mailing list