I am working on a script that parses a csv file. The actual
field delimiters in the file are pipes |. The problem I am running into
is that if the field is empty, then the database is getting a '0' rather
than 'NULL' as it should. The column is setup properly with NULLs
allowed and the default value of NULL. Here is a sample of the file
being parsed...
SANDBOX|0|750|0.0|junk|N|0.0|9000/800/RP7410|Unknown|B.11.11|junk|junk|s
erial number|Sandbox|hostname|0||CHTSAN|UNKNOWN|ROBERT C|JONES SR.|
The problem on this line is the field between '0' and 'CHTSAN'.
This ends up as a zero in the database. When I parse the file again to
compare the values, this comes up as a mismatch when it should actually
be a match. How do I fix this? Thanks in advance for any help. Here
is the pertinent code.
foreach $n (0..20) { #
$file_val is the data from the parsed file.
chomp($file_val = $data[$n]);
$file_val =~ s/\s*$//;
chomp($db_val = $old[$n+1]); #
$db_val is the data coming from the DB.
# print "Comparing $file_val to $db_val. \n"; # Testing line
if ($file_val eq $db_val) {
$update = 1;
} else {
$update = 0;
# print "Comparing $file_val to $db_val. \n"; # Testing line
last;
}
Scott Nipp
Phone: (214) 858-1289
E-mail: [EMAIL PROTECTED]
Web: http:\\ldsa.sbcld.sbc.com