protected function parseCsv($filename, ConfigurationInterface $config)
    {
        $length = $config->getLength();
        $delimiter = $config->getDelimiter();
        $enclosure = $config->getEnclosureChar();
        $escape = $config->getEscapeChar();
        $result = [];

        if (($handle = fopen($filename, 'r')) !== false) {
            while (($row = fgetcsv($handle, $length, $delimiter, $enclosure, $escape)) !== false) {
                $temp = [];

                if (empty($this->attributes)) {
                    if ($config->isFirstLineAsAttributes()) {
                        $this->attributes = $row;
                    } else {
                        $cRow = count($row);
                        for ($i = 0; $i < $cRow; ++$i) {
                            $attrName = 'attribute '.$i;
                            $this->attributes[] = $attrName;
                            $temp[$attrName] = trim($row[$i]);
                        }
                        $result[] = $temp;
                    }
                } else {
                    $cRow = count($row);
                    for ($i = 0; $i < $cRow; ++$i) {
                        $attrName = $this->attributes[$i];
                        $temp[$attrName] = trim($row[$i]);
                    }
                    $result[] = $temp;
                }
            }
            fclose($handle);
        }

        return $result;
    }