/** * Parses the given CSV-File into an Array * * @return array The content of the CSV-File with properly named keys */ private function csvParse() { if (!empty($_FILES['csvFile']['tmp_name'])) { $fileWithExtension = $_FILES['csvFile']['tmp_name'] . '.' . pathinfo($_FILES['csvFile']['name'], PATHINFO_EXTENSION); rename($_FILES['csvFile']['tmp_name'], $fileWithExtension); $reader = new \SpreadsheetImporter($fileWithExtension); $reader->openFile(); $reader->parseFile(); return $reader->getContent(); // $reader = new \CsvReader($_FILES['csvFile']['tmp_name'], ';'); } else { $this->_logger->log(__METHOD__ . ': Could not find uploaded file', 'Notice', Null); $this->_interface->dieError(_g('Could not find uploaded file')); } // $reader->readContents(); // return $reader->getContents(); }
/** * Extracts the content from the file * @param String $filepath The path to the file * @return array The content of the file */ private function fileContentGet($filepath) { if (!empty($_FILES['csvFile']['tmp_name'])) { $fileWithExtension = $_FILES['csvFile']['tmp_name'] . '.' . pathinfo($_FILES['csvFile']['name'], PATHINFO_EXTENSION); rename($_FILES['csvFile']['tmp_name'], $fileWithExtension); $reader = new \SpreadsheetImporter($fileWithExtension); $reader->openFile(); $reader->parseFile(); return $reader->getContent(); } else { $this->_logger->log(__METHOD__ . ': Could not find uploaded file', 'Notice', Null); $this->_interface->dieError('Konnte die hochgeladene Datei ' . 'nicht finden'); } }