Bama_Perl has asked for the wisdom of the Perl Monks concerning the following question:
I want to remove the line IF the 8th column numeric value is < -10 or > 10. Here's my code so far:XP.sta1 -41.5166 0.0513 0.6842 0.1794 0 CPHI.BHZ 300 +.2458 -42.2436 XP.sta2 3.5972 0.0500 0.7699 0.1213 0 E000.BHZ 30 +0.5616 2.5545 XP.sta3 3.7112 0.0267 0.7813 0.1457 0 E002.BHZ 30 +0.6140 2.6160 XP.sta4 4.2891 0.0214 0.6870 0.1308 0 E004.BHZ 30 +1.2073 2.6006
I am reading through multiple files, and for lines in between 2 and "stop" I want to remove that line if the 8th column value is <-10 or > 10. From the input above, I want to remove the line beginning with XP.sta1, since the 8th column is -40. How do I do this without simply deleting the 8th column value? This script is slightly modified, but if I run with the above code structure, the output is this:open(TABLEC,$mFile); @tablec = <TABLEC>; for ($j = 2; $j < $stop; $j++) { chomp ($tablec[$j]); ($netSta,$delayTime) = (split /\s+/,$tablec[$j])[1,9]; next if $delayTime < -10 or $delayTime > 10;
Where in the 8th column, that value of -42.4326 is removed, but not the entire line. How do I delete the entire line, rather than just the value in column 8? Thanks for the help.XP.sta1 -41.5166 0.0513 0.6842 0.1794 0 CPHI.BHZ 30 +0.2458 2.5545 XP.sta2 3.5972 0.0500 0.7699 0.1213 0 E000.BHZ 30 +0.5616 2.6160 XP.sta3 3.7112 0.0267 0.7813 0.1457 0 E002.BHZ 30 +0.6140 2.6006 XP.sta4 4.2891 0.0214 0.6870 0.1308 0 E004.BHZ 30 +1.2073
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Remove line from file based on numeric column value
by aaron_baugher (Curate) on May 25, 2015 at 21:59 UTC | |
|
Re: Remove line from file based on numeric column value
by johngg (Canon) on May 25, 2015 at 23:06 UTC | |
by Bama_Perl (Acolyte) on May 25, 2015 at 23:29 UTC | |
|
Re: Remove line from file based on numeric column value
by ww (Archbishop) on May 26, 2015 at 12:10 UTC |