/**
  * Initializes rows and fields from CSV file
  * @param resource $fp File pointer, obtained with {@link fopen()}
  * @param SQLICSVOptions $options
  * @return SQLICSVRowSet
  */
 public static function fromCSVFile($fp, SQLICSVOptions $options = null)
 {
     if (!$options instanceof SQLICSVOptions) {
         $options = new SQLICSVOptions();
     }
     $set = new self();
     $i = 0;
     while ($data = fgetcsv($fp, $options['csv_line_length'], $options['delimiter'], $options['enclosure'])) {
         //echo "Working on CSV row #$i\n";
         if ($i == 0) {
             $set->setRowHeaders($data);
             $i++;
             unset($data);
             continue;
         }
         $aRowData = array();
         $headers = $set->getHeaders();
         for ($j = 0, $jMax = count($headers); $j < $jMax; ++$j) {
             $aRowData[$headers[$j]] = $data[$j];
         }
         unset($headers, $data);
         $row = new SQLICSVRow($aRowData);
         $set->rows[] = $row;
         unset($aRowData);
         $i++;
     }
     $set->initIterator();
     return $set;
 }