protected static function parseData(array $rawData): array
    {
        $data = [];
        $tableName = null;
        $fieldCount = null;
        $idIndex = null;
        foreach ($rawData as $values) {
            if (!empty($values[0])) {
                // Skip comment lines, starting with "#"
                if ($values[0]{0} === '#') {
                    continue;
                }
                $tableName = $values[0];
                $fieldCount = null;
                $idIndex = null;
                if (!isset($data[$tableName])) {
                    $data[$tableName] = [];
                }
            } elseif (implode('', $values) === '') {
                $tableName = null;
                $fieldCount = null;
                $idIndex = null;
            } elseif ($tableName !== null && !empty($values[1])) {
                array_shift($values);
                if (!isset($data[$tableName]['fields'])) {
                    $data[$tableName]['fields'] = [];
                    foreach ($values as $value) {
                        if (empty($value)) {
                            continue;
                        }
                        $data[$tableName]['fields'][] = $value;
                        $fieldCount = count($data[$tableName]['fields']);
                    }
                    if (in_array('uid', $values)) {
                        $idIndex = array_search('uid', $values);
                        $data[$tableName]['idIndex'] = $idIndex;
                    }
                } else {
                    if (!isset($data[$tableName]['elements'])) {
                        $data[$tableName]['elements'] = [];
                    }
                    $values = array_slice($values, 0, $fieldCount);
                    foreach ($values as &$value) {
                        if ($value === '\\NULL') {
                            $value = null;
                        }
                    }
                    unset($value);
                    $element = array_combine($data[$tableName]['fields'], $values);
                    if ($idIndex !== null) {
                        $data[$tableName]['elements'][$values[$idIndex]] = $element;
                    } else {
                        $data[$tableName]['elements'][] = $element;
                    }
                }
            }
        }
        return $data;
    }
protected static function parseData(array $rawData): array
    {
        $data = [];
        $tableName = null;
        $fieldCount = null;
        $idIndex = null;
        foreach ($rawData as $values) {
            if (!empty($values[0])) {
                // Skip comment lines, starting with "#"
                if ($values[0]{0} === '#') {
                    continue;
                }
                $tableName = $values[0];
                $fieldCount = null;
                $idIndex = null;
                if (!isset($data[$tableName])) {
                    $data[$tableName] = [];
                }
            } elseif (implode('', $values) === '') {
                $tableName = null;
                $fieldCount = null;
                $idIndex = null;
            } elseif ($tableName !== null && !empty($values[1])) {
                array_shift($values);
                if (!isset($data[$tableName]['fields'])) {
                    $data[$tableName]['fields'] = [];
                    foreach ($values as $value) {
                        if (empty($value)) {
                            continue;
                        }
                        $data[$tableName]['fields'][] = $value;
                        $fieldCount = count($data[$tableName]['fields']);
                    }
                    if (in_array('uid', $values)) {
                        $idIndex = array_search('uid', $values);
                        $data[$tableName]['idIndex'] = $idIndex;
                    }
                } else {
                    if (!isset($data[$tableName]['elements'])) {
                        $data[$tableName]['elements'] = [];
                    }
                    $values = array_slice($values, 0, $fieldCount);
                    foreach ($values as &$value) {
                        if ($value === '\\NULL') {
                            $value = null;
                        }
                    }
                    unset($value);
                    $element = array_combine($data[$tableName]['fields'], $values);
                    if ($idIndex !== null) {
                        $data[$tableName]['elements'][$values[$idIndex]] = $element;
                    } else {
                        $data[$tableName]['elements'][] = $element;
                    }
                }
            }
        }
        return $data;
    }
protected static function parseData ( array $ rawData ) : array { $ data = [ ] ; $ tableName = null ; $ fieldCount = null ; $ idIndex = null ; foreach ( $ rawData as $ values ) { if ( ! empty ( $ values [ 0 ] ) ) { // Skip comment lines, starting with "#" if ( $ values [ 0 ] { 0 } === '#' ) { continue ; } $ tableName = $ values [ 0 ] ; $ fieldCount = null ; $ idIndex = null ; if ( ! isset ( $ data [ $ tableName ] ) ) { $ data [ $ tableName ] = [ ] ; } } elseif ( implode ( '' , $ values ) === '' ) { $ tableName = null ; $ fieldCount = null ; $ idIndex = null ; } elseif ( $ tableName !== null && ! empty ( $ values [ 1 ] ) ) { array_shift ( $ values ) ; if ( ! isset ( $ data [ $ tableName ] [ 'fields' ] ) ) { $ data [ $ tableName ] [ 'fields' ] = [ ] ; foreach ( $ values as $ value ) { if ( empty ( $ value ) ) { continue ; } $ data [ $ tableName ] [ 'fields' ] [ ] = $ value ; $ fieldCount = count ( $ data [ $ tableName ] [ 'fields' ] ) ; } if ( in_array ( 'uid' , $ values ) ) { $ idIndex = array_search ( 'uid' , $ values ) ; $ data [ $ tableName ] [ 'idIndex' ] = $ idIndex ; } } else { if ( ! isset ( $ data [ $ tableName ] [ 'elements' ] ) ) { $ data [ $ tableName ] [ 'elements' ] = [ ] ; } $ values = array_slice ( $ values , 0 , $ fieldCount ) ; foreach ( $ values as & $ value ) { if ( $ value === '\\NULL' ) { $ value = null ; } } unset ( $ value ) ; $ element = array_combine ( $ data [ $ tableName ] [ 'fields' ] , $ values ) ; if ( $ idIndex !== null ) { $ data [ $ tableName ] [ 'elements' ] [ $ values [ $ idIndex ] ] = $ element ; } else { $ data [ $ tableName ] [ 'elements' ] [ ] = $ element ; } } } } return $ data ; }
Parses CSV data.

Special values are:
+ "\NULL" to treat as NULL value
+ "\*" to ignore value during comparison

@param array $rawData
@return array
Parses CSV data .