Get total number of data rows (exclusive heading line if present) in CSV
without parsing the whole data string.

@return bool|int
548078
public function getTotalDataRowCount() {
        if (empty($this->file_data)) {
            return false;
        }

        $data = $this->file_data;

        $this->_detect_and_remove_sep_row_from_data($data);

        $pattern = sprintf('/%1$s[^%1$s]*%1$s/i', $this->enclosure);
        preg_match_all($pattern, $data, $matches);

        /** @var array[] $matches */
        foreach ($matches[0] as $match) {
            if (empty($match) || (strpos($match, $this->enclosure) === false)) {
                continue;
            }

            $replace = str_replace(["\r", "\n"], '', $match);
            $data = str_replace($match, $replace, $data);
        }

        $headingRow = $this->heading ? 1 : 0;

        $count = substr_count($data, "\r")
            + substr_count($data, "\n")
            - substr_count($data, "\r\n")
            - $headingRow;

        return $count;
    }
274894
public function getTotalSelectedRowsWithoutLimit(): int
    {
        if (!$this->require_to_count_total_rows) {
            dump('You need to call setRequireCountRowsWithoutLimits(true) before requesting result');
        }

        $this->collectObjects();

        return (int)$this->total_count_rows;
    }
1360550
private function getTotalCount(): int
    {
        if ($this->totalCount === -1) {
            $this->setTotalCount($this->getLastResponse()->getTotal());
        }

        return $this->totalCount;
    }
841023
protected function getNextDataSet()
    {
        $set = $this->file->fgetcsv($this->delimiter, $this->enclosure, $this->escape);

        if (is_array($set) && 1 === count($set) && null === $set[0]) {
            if ($this->skipEmptyLines && !$this->file->eof()) {
                return $this->getNextDataSet();
            }

            return null;
        }

        if ($this->removeBom) {
            if (substr($set[0], 0, 3) == pack("CCC", 0xef, 0xbb, 0xbf)) {
                $set[0] = substr($set[0], 3);
            }
            $this->removeBom = false;
        }

        $set = $this->convertEncoding($set);

        $this->line++;

        return $set;
    }
1352785
public function count()
	{
		$count = 0;

		for ($index = 0, $length = strlen($this->data); $index < $length; $index++)
		{
			$count += self::$count[ord($this->data[$index])];
		}

		return $count;
	}
518437
public function getItemCount() : int
    {
        if($this->lastResponse && $this->lastResponse->getHeaderLine('X-Total-Count')) {
            return (int)$this->lastResponse->getHeaderLine('X-Total-Count');
        }

        return 0;
    }
1357209
public function getLineCount() {
    $count = 1;

    $this
      ->find(Filter::isInstanceOf('\Pharborist\WhitespaceNode'))
      ->each(function(WhitespaceNode $node) use (&$count) {
        $count += $node->getNewlineCount();
      });

    return $count;
  }
1020558
public function numRows(): ?int
	{
		$regex = '/^SELECT\s+(?:ALL\s+|DISTINCT\s+)?(?:.*?)\s+FROM\s+(.*)$/i';
		$output = [];

		if (preg_match($regex, $this->lastQuery, $output) > 0)
		{
			$stmt = $this->query("SELECT COUNT(*) FROM {$output[1]}");
			return (int) $stmt->fetchColumn();
		}

		return NULL;
	}
628552
public function getTotalItemCount()
    {
        if ($this->rowCount !== null) {
            return $this->rowCount;
        }

        $param = null;

        if (is_array($this->select)) {
            $select = $this->select[0];
            $param = $this->select[1];
            $adt = $this->sql->getAdapter();

            $statement = $adt->query(sprintf("SELECT COUNT(1) AS c FROM (%s) AS original_select", $select), $adt::QUERY_MODE_PREPARE);
        } else {
            $select = clone $this->select;
            $select->reset(Select::LIMIT);
            $select->reset(Select::OFFSET);
            $select->reset(Select::ORDER);

            $countSelect = new Select();
            $countSelect->columns(array('c' => new Expression('COUNT(1)')));
            $countSelect->from(array('original_select' => $select));

            $statement = $this->sql->prepareStatementForSqlObject($countSelect);
        }

        $result = $statement->execute($param);
        $row = $result->current();

        $this->rowCount = $row['c'];

        return $this->rowCount;
    }
510098
public function count()
    {
        $total = 0;
        foreach ($this->file as $line)
        {
            $total++;
        }
        if ($this->useFirstRecordAsHeader && $total > 0)
        {
            $total--;
        }
        return $total;
    }
1267989
public function count()
    {
        $limit = $this->_limit;
        $offset = $this->_offset;
        $this->limit(0);

        $joins = $this->getJoins();
        $copyJoins = clone($joins);
        
        $keys = array_keys($copyJoins->getArrayCopy());
        foreach ($keys as $key) {
            $joins[$key]['fields'] = array();
        }

        $this->_joins = $joins;

        $fields = $this->_fields;
        $this->_fields = array('COUNT(*) AS totalRows');
        $prefix = $this->_prefixTableName;
        $this->_prefixTableName = false;

        $result = $this->all();

        $this->_prefixTableName = $prefix;
        $this->_fields = $fields;
        $this->_joins = $copyJoins; 
        $this->_limit  = $limit;
        $this->_offset = $offset;
        return (isset($result[0]['totalRows'])) ? $result[0]['totalRows'] : 0;
    }
18482
protected function getNextRow()
    {
        if ($this->position >= $this->totalRows) {
            return;
        }

        if ($this->indexMap) {
            $rowIndex = $this->indexMap[$this->position];
        } else {
            $rowIndex = $this->position;
        }

        $data = Json::decodeFromFile($this->dir . "/" . $rowIndex . ".row");

        $this->position++;

        return $data;
    }
252964
public function getRowsCount()
    {
        if (is_null($this->summaryRow)) {
            return count($this->rows);
        } else {
            return count($this->rows) + 1;
        }
    }
805348
public function getRowCount()
    {
        $this->parseDefer();
        if(!$this->isSuccess)
        {
            throw new \RuntimeException('Result is not success!');
        }
        return count($this->statement->fetchAll());
    }
644161
public function count()
    {
        return isset($this->raw['size'])
            ? (int) $this->raw['size']
            : (isset($this->raw['data']) && is_array($this->raw['data'])
                ? count($this->raw['data'])
                : null);
    }
587566
public function getContentLength()
    {
        // The content length for a record is the length of the record contents section measured in 16-bit words.
        // one coordinate makes 4 16-bit words (64 bit double)
        switch ($this->shapeType) {
            case 0:
                $result = 0;
                break;
            case 1:
                $result = 10;
                break;
            case 21:
                $result = 10 + 4;
                break;
            case 11:
                $result = 10 + 8;
                break;
            case 3:
            case 5:
                $count = count($this->SHPData['parts']);
                $result = 22 + 2 * $count;
                for ($i = 0; $i < $count; ++$i) {
                    $result += 8 * count($this->SHPData['parts'][$i]['points']);
                }
                break;
            case 23:
            case 25:
                $count = count($this->SHPData['parts']);
                $result = 22 + (2 * 4) + 2 * $count;
                for ($i = 0; $i < $count; ++$i) {
                    $result += (8 + 4) * count($this->SHPData['parts'][$i]['points']);
                }
                break;
            case 13:
            case 15:
                $count = count($this->SHPData['parts']);
                $result = 22 + (4 * 4) + 2 * $count;
                for ($i = 0; $i < $count; ++$i) {
                    $result += (8 + 8) * count($this->SHPData['parts'][$i]['points']);
                }
                break;
            case 8:
                $result = 20 + 8 * count($this->SHPData['points']);
                break;
            case 28:
                $result = 20 + (2 * 4) + (8 + 4) * count($this->SHPData['points']);
                break;
            case 18:
                $result = 20 + (4 * 4) + (8 + 8) * count($this->SHPData['points']);
                break;
            default:
                $result = false;
                $this->setError(sprintf('The Shape Type "%s" is not supported.', $this->shapeType));
                break;
        }

        return $result;
    }
1033807
public function getCount()
	{
		if ( $this->empty ) return 0;

		if ( $this->src->getIsFinished() )
		{
			return count( $this->buffer );
		}
		return parent::getCount();
	}