On Tue, 2003-01-14 at 09:24, Michael Lake wrote:
> Hi all,
> 
> This is a bit OT but I am trying to fix up some MySQL data on a Linux
> system and having just one problem
> Numeric types that have no entry end up as 0.00000 rather than NULL when
> imported into the tables.

Hmm.. I thought at first table declaration wrong. Maybe try converting
the file to a tab delimited one. I'm thinking it may be interpreting ""
as NOT NULL.

You say you don't want to change the input file. Fine write a perl
script to do it. Either go & use the DBI module or for something quick,
just write a filter to output mysql commands.

#!/usr/bin/perl

while (<STDIN>)
{
        chop; # remove end-of-line
        my @row = split /,/; #break into fields
        $row[3]="NULL" if $row[3] eq '""';
        print "insert into test (sheet_name, map_scale, map_latitude) "         print
"values (",join(",",@row)),");\n";
}

-- 
---<GRiP>--- 
Web: www.arcadia.au.com/gripz 
Mobile: 0408 686 201
-- 
SLUG - Sydney Linux User's Group - http://slug.org.au/
More Info: http://lists.slug.org.au/listinfo/slug

Reply via email to