Beispiel #1
0
 public function pluck($offset, $count = 0)
 {
     $rows = new Collection();
     foreach ($this->rows as $row) {
         $counter = 0;
         $newRow = [];
         foreach ($row as $index => $cell) {
             if ($index >= $offset && $index < $count + $offset) {
                 $newRow[] = $cell;
             }
             $counter++;
         }
         $rows->push($newRow);
     }
     return $rows;
 }
Beispiel #2
0
 public function read($offset = 0, $count = 0, $delimiter = null)
 {
     if (!$this->handle) {
         throw new FileNotOpenException();
     }
     if (!$delimiter) {
         $delimiter = $this->testDelimiters();
     }
     $rows = new Collection();
     $counter = 0;
     rewind($this->handle);
     while (($data = fgetcsv($this->handle, self::READ_LENGTH, $delimiter, Komma::CSV_ENCLOSURE, Komma::CSV_ESCAPE)) !== false && (!$count || $counter < $count + $offset)) {
         $counter++;
         if ($counter >= $offset) {
             $rows->push($data);
         }
     }
     $this->rows = new Rows($rows);
     return $this->rows;
 }