Deleting rows in a file based on condition
От | Ken Hill |
---|---|
Тема | Deleting rows in a file based on condition |
Дата | |
Msg-id | 1139593968.30696.10.camel@localhost.localdomain обсуждение исходный текст |
Ответы |
Re: Deleting rows in a file based on condition
|
Список | pgsql-sql |
I have the following perl script that reads a fixed-width file and replaces values in various sections of the file.<br /><br/> -------------------------------------------<br /> open (IN, '< in.txt');<br /> open (OUT, '> out_test.txt');<br/><br /> while (<IN>) {<br /><br /> chomp;<br /><br /> $first_section = substr$_, 0, 381; # extract the first section of the record<br /> $facilityno = substr $_, 381, 10; # extractthe facilityno field<br /> $second_section = substr $_, 391, 1056; # extract the second section ofthe record<br /> $requestor_section=" " x 500;<br /> # $requestor_section = substr $_, 1446, 499; # extractrequestor section of record<br /> $third_section = substr $_, 1946, 4748; # extract third section of record<br/> <br /> # print out the file with changed facilityno value ...<br /><br /> printOUT "$first_section$\0039007300$\$second_section$\$requestor_section$\$third_section\n";<br /> <br /> }<br/><br /> close (IN);<br /> close (OUT);<br /> ------------------------------------------------<br /><br /> I want toplace 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.<br /><br /> Anyadvice is very much appreciated.<br /><br />
В списке pgsql-sql по дате отправления: