What does an error of "Column count does not match row count?"

wecc's Avatar, Join Date: Aug 2009
Newbie Member
When I run my perl script to try and load multiple rows into a mysql table at once I recieve an error that says "Column count does not match row count" I need to load about 325 million rows of data from files into mysql and believe that this is probably the fastest way so I would like to know why it won't work. If there is a much faster way to load this data that would also be greatly appreciated! Thank you so much for the help!
Code:
                open(FILE, $filename) or die "$!";
                @uwind = <FILE>;

                $filename =~ s/u.txt/v.txt/;

                open(FILE, $filename) or die "$!";
                @vwind = <FILE>;
                                  $y=-4612.566;
                #for ($y=-4612.566; $y<=4300; $y=$y+32.463) {
            for ($x=-5632.668; $x<=-5600; $x=$x+32.463) {

                                $i = $i + 1;


                               if ($uwind[$i] < 100 && $vwind[$i] < 100) {
                               
                                $rho = sqrt($x*$x + ($rhozero - $y)*($rhozero - $y));
                                $theta = atan2($x,($rhozero - $y));
                                $lat = (2*atan(($R*$F/$rho)**(1/$N)) - $pi/2) * $degs;
                                $longi = (($theta/$N) * $degs) + $lambda0;

                                $resultant = sqrt($uwind[$i]**2 + $vwind[$i]**2);
                                $angle = (atan2($vwind[$i],$uwind[$i])) * $degs;
                                        if ($angle<0) {
                                        $angle=$angle + 360;
                                       }

                                $variance_speed = 0;
                                $variance_angle = 0;

                                $onestring = 1000000 + $i . ",'" . $date . "','" . $hour . "'," . int($lat*100)/100 . ',' . int($longi*100)/100 . ',' . int($x*100)/100;
                                $onestring = $onestring . ',' . int($y*100)/100 . ',' . int($uwind[$i]*100)/100 . ',' . int($vwind[$i]*100)/100 . ',' . int($resultant*100)/100 . ',' . $variance_speed . ',' . int($angle*100)/100 . ',' . $variance_angle;
                                 print $onestring . "\n";
                                 if ($bigstring) {
                                     $bigstring = $bigstring . ',(' . $onestring . ')';
                                }
                                else {
                                   $bigstring = '(' . $onestring . ')';
                                }

                                print $bigstring . "\n";
                             } # if
                    } # x
                        $sth=$dbh->prepare
                                ("INSERT INTO 30m     (ID, DATE, TIME, LATITUDE, LONGITUDE, X, Y, U, V, RESULTANT, VARIANCE_RESULTANT, ANGLE, VARIANCE_ANGLE)
                                VALUES    ($bigstring)");
                                $sth->execute () || die "Couldn't insert record : $DBI::errstr";
                       print "Data loaded into database\n";
                   #} # y
shency's Avatar, Join Date: Oct 2008
Go4Expert Member
That the number of columns you have specified is not equal to the number of values you are passing. Say you have 10 columns, so while insert you have to pass 10 values!
naimish like this
naimish's Avatar
Banned
Yeah..nice caught shency.
Saket's Avatar
Banned
exactly correct shency