Jump to content

fgetcsv missing first line


ejaboneta

Recommended Posts

The first line of each csv I upload goes missing! Anyone know why?

 

<?php
  $row = 0;
  $handle = fopen("$file", "r");  
  $data = fgetcsv($handle, 1000, ",");
  
  while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
    $num = count($data);
    $newvalues[firstname] = $data[0];
    $newvalues[lastname] = $data[1];
    $newvalues[birthday] = $data[3];
    $newvalues[address] = $data[4];
    $newvalues[city] = $data[5];
    $newvalues[state] = $data[6];
    $newvalues[zip] = $data[7];
    $newvalues[phone] = $data[9];
    $newvalues[sex] = $data[11];
     $row++;

      echo "<br>";
      $fdf_file=time(). rand(0,100) . '.fdf';
      $fdf_dir=dirname(__FILE__).'/results';
      $pdf_doc='Cigna.pdf';
      $fdf_data=createFDF('Cigna.pdf',$newvalues);
      if($fp=fopen($fdf_dir.'/'.$fdf_file,'w')){
                fwrite($fp,$fdf_data,strlen($fdf_data));
                echo $fdf_file,' written successfully.';
            }else{
                die('Unable to create file: '.$fdf_dir.'/'.$fdf_file);
            }
  }                 
  fclose($handle); ?>

Link to comment
https://forums.phpfreaks.com/topic/177029-fgetcsv-missing-first-line/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.