McMahon has asked for the wisdom of the Perl Monks concerning the following question:
ADT,,111111111,,*SOH,5.00,,,,,,,,# ADS,,222222222,,*SOH,1312.00,,,,,,,,# ADS,,111111111,,*FWT,14.00,,,,,,,,# ADS,,222222222,,*UNLF,99.75,,,,,,,,#
use warnings; use strict; use DBI; open (OUT, ">file.txt"); my @chk = (111111111,222222222); my $dbh = DBI->connect(qq{DBI:CSV:csv_sep_char=\\,}); $dbh->{'csv_tables'}->{'comp'} = { 'file' => 'DUDS.csv'}; my $sql; my @row ; my $sth = $dbh->prepare("SELECT * from comp"); $sth->execute(); while (my @row = $sth->fetchrow_array) { foreach my $chk(@chk) { if ( $chk == $row[2]) { print OUT "@row\n"; print OUT "$row[0],$row[1],$row[2],$row[3],$row[4],$row[5],$row[6],$ro +w[7]\n\n"; last; } } }
ADS 222222222 *SOH # ADS,,222222222,,*SOH,,, ADS 111111111 *FWT # ADS,,111111111,,*FWT,,, ADS 222222222 *UNLF # ADS,,222222222,,*UNLF,,,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: DBD::CSV forgets a column and a row?
by merlyn (Sage) on Aug 16, 2004 at 14:52 UTC | |
|
Re: DBD::CSV forgets a column and a row?
by jZed (Prior) on Aug 16, 2004 at 15:38 UTC | |
by McMahon (Chaplain) on Aug 16, 2004 at 15:52 UTC | |
by jZed (Prior) on Aug 16, 2004 at 15:54 UTC | |
by McMahon (Chaplain) on Aug 16, 2004 at 15:59 UTC | |
|
Re: DBD::CSV forgets a column and a row?
by ikegami (Patriarch) on Aug 16, 2004 at 15:40 UTC |