src/Utility/Import.php
public static function getRowsCount(string $path, bool $withHeader = false) : int
    {
        $result = trim(exec("/usr/bin/env wc -l '" . $path . "'", $output, $return));
        if (0 === $return) {
            list($result, ) = explode(' ', $result);
            $result = (int)$result;
            if (0 < $result) {
                $result -= 1;
            }

            return $result;
        }

        $reader = Reader::createFromPath($path, 'r');

        $result = $reader->each(function ($row) {
            return true;
        });

        if (! $withHeader) {
            $result = $result - 1;
        }

        return $result;
    }
public static function getRowsCount(string $path, bool $withHeader = false) : int
    {
        $result = trim(exec("/usr/bin/env wc -l '" . $path . "'", $output, $return));
        if (0 === $return) {
            list($result, ) = explode(' ', $result);
            $result = (int)$result;
            if (0 < $result) {
                $result -= 1;
            }

            return $result;
        }

        $reader = Reader::createFromPath($path, 'r');

        $result = $reader->each(function ($row) {
            return true;
        });

        if (! $withHeader) {
            $result = $result - 1;
        }

        return $result;
    }
public static function getRowsCount ( string $ path , bool $ withHeader = false ) : int { $ result = trim ( exec ( "/usr/bin/env wc -l '" . $ path . "'" , $ output , $ return ) ) ; if ( 0 === $ return ) { list ( $ result , ) = explode ( ' ' , $ result ) ; $ result = ( int ) $ result ; if ( 0 < $ result ) { $ result -= 1 ; } return $ result ; } $ reader = Reader :: createFromPath ( $ path , 'r' ) ; $ result = $ reader -> each ( function ( $ row ) { return true ; } ) ; if ( ! $ withHeader ) { $ result = $ result - 1 ; } return $ result ; }
Get CSV file rows count.

@param string $path File path
@param bool $withHeader Include header row into the count
@return int
Get CSV file rows count .