/**
  * Akce pro vygenerování náhledu na data
  * @param string $file
  * @param string $separator
  * @param string $encoding
  * @param string $enclosure
  * @param string $escape
  * @param string $nullValue="none"
  */
 public function renderImportCsvDataPreview($file, $separator = ',', $encoding = 'utf8', $enclosure = '"', $escape = '\\', $nullValue = "none")
 {
     $this->layout = 'blank';
     $this->fileImportsFacade->changeFileEncoding($file, $encoding);
     $this->template->colsCount = $this->fileImportsFacade->getColsCountInCSV($file, $separator, $enclosure, $escape);
     $rows = $this->fileImportsFacade->getRowsFromCSV($file, 20, $separator, $enclosure, $escape, $nullValue == 'none' ? null : $nullValue, 0);
     $rows[0] = CsvImport::sanitizeColumnNames($rows[0]);
     $this->template->rows = $rows;
 }
 /**
  * Akce pro zobrazení náhledu na prvních X řádků nahrávaného souboru - pracující s lokálními soubory...
  * @param string $file
  * @param string $delimiter
  * @param string $encoding
  * @param string $enclosure
  * @param string $escapeCharacter
  * @param string $nullValue
  * @param string $locale
  * @param int $rowsCount = 20
  * @throws BadRequestException
  */
 public function actionPreviewData($file, $delimiter = '', $encoding = 'utf-8', $enclosure = '"', $escapeCharacter = '\\', $nullValue = '', $locale = 'en', $rowsCount = 20)
 {
     //TODO detekce locale... (podle desetinné tečky/čárky...)
     if ($delimiter == '') {
         //detekce výchozího separátoru
         $delimiter = $this->fileImportsFacade->getCSVDelimiter($file);
     }
     //změna kódování souboru
     $this->fileImportsFacade->changeFileEncoding($file, $encoding);
     //připravení výstupního pole s daty
     $resultArr = ['config' => ['delimiter' => $delimiter, 'encoding' => $encoding, 'enclosure' => $enclosure, 'escapeCharacter' => $escapeCharacter, 'nullValue' => $nullValue, 'locale' => $locale], 'columnNames' => [], 'dataTypes' => [], 'data' => []];
     //načtení informací o datových sloupcích
     $columns = $this->fileImportsFacade->getColsInCSV($file, $delimiter, $enclosure, $escapeCharacter, $rowsCount + 1);
     if (empty($columns)) {
         throw new BadRequestException('No columns detected!');
     }
     foreach ($columns as $column) {
         $resultArr['columnNames'][] = $column->name;
         $resultArr['dataTypes'][] = $column->type == DbField::TYPE_NOMINAL ? 'nominal' : 'numeric';
     }
     //načtení potřebných řádků...
     $resultArr['data'] = $this->fileImportsFacade->getRowsFromCSV($file, $rowsCount, $delimiter, $enclosure, $escapeCharacter, $nullValue, 1);
     //odeslání kompletní odpovědi...
     $this->sendJsonResponse($resultArr);
 }