Re: Deleting rows in a file based on condition - Mailing list pgsql-sql

From Ken Hill
Subject Re: Deleting rows in a file based on condition
Date
Msg-id 1139594402.30696.16.camel@localhost.localdomain
Whole thread Raw
In response to Deleting rows in a file based on condition  (Ken Hill <ken@scottshill.com>)
List pgsql-sql
Oops. I posted this to the wrong support list. Sorry.<br /><br /> -Ken<br /><br /> On Fri, 2006-02-10 at 09:52 -0800,
KenHill wrote:<br /><blockquote type="CITE"><font color="#000000">I have the following perl script that reads a
fixed-widthfile and replaces values in various sections of the file.</font><br /><br /><font
color="#000000">-------------------------------------------</font><br/><font color="#000000">open (IN, '<
in.txt');</font><br/><font color="#000000">open (OUT, '> out_test.txt');</font><br /><br /><font
color="#000000">while(<IN>) {</font><br /><br /><font color="#000000">          chomp;</font><br /><br /><font
color="#000000">         $first_section = substr $_, 0, 381;     # extract the first section of the record</font><br
/><fontcolor="#000000">          $facilityno = substr $_, 381, 10;    # extract the facilityno field</font><br /><font
color="#000000">         $second_section = substr $_, 391, 1056;        # extract the second section of the
record</font><br/><font color="#000000">          $requestor_section=" " x 500;</font><br /><font color="#000000">  #
$requestor_section= substr $_, 1446, 499; # extract requestor section of record</font><br /><font
color="#000000">         $third_section = substr $_, 1946, 4748; # extract third section of record</font><br /><font
color="#000000">         </font><br /><font color="#000000">          # print out the file with changed facilityno
value...</font><br /><br /><font color="#000000">          print OUT
"$first_section$\0039007300$\$second_section$\$requestor_section$\$third_section\n";</font><br/><font
color="#000000">         </font><br /><font color="#000000">}</font><br /><br /><font color="#000000">close
(IN);</font><br/><font color="#000000">close (OUT);</font><br /><font
color="#000000">------------------------------------------------</font><br/><br /><font color="#000000">I want to place
an"if...then" condition on the $facilityno value; such that if the $facilityno value = 0000000000, delete the record
(e.g.,don't print out that row); rather skip that row and continue printing out the remaining rows.</font><br /><br
/><fontcolor="#000000">Any advice is very much appreciated.</font><br /><br /></blockquote> 

pgsql-sql by date:

Previous
From: Ken Hill
Date:
Subject: Deleting rows in a file based on condition
Next
From: Osvaldo Rosário Kussama
Date:
Subject: Re: date