1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'MySQL' started by wecc, Aug 4, 2009.

  1. wecc

    wecc New Member

    Joined:
    Aug 4, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    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
    
     
  2. shency

    shency New Member

    Joined:
    Oct 25, 2008
    Messages:
    14
    Likes Received:
    0
    Trophy Points:
    0
    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!
     
  3. naimish

    naimish New Member

    Joined:
    Jun 29, 2009
    Messages:
    1,046
    Likes Received:
    18
    Trophy Points:
    0
    Occupation:
    Software Engineer
    Location:
    On Earth
    Yeah..nice caught shency.
     
  4. Saket

    Saket New Member

    Joined:
    Jul 21, 2009
    Messages:
    42
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Don't Know
    exactly correct shency
     

Share This Page