function csv($fileName, $colNames) { $dataIndexed = array_map('str_getcsv', array_map('trim', explode("\n", file_get_contents($fileName)))); $cols = parseCols($colNames); $data = array_map(function ($indexedRow) use($cols) { return array_combine($cols, $indexedRow); }, $dataIndexed); return function () use($cols, $data) { return (object) array('data' => $data, 'columns' => $cols); }; } } namespace { $loader = (require_once __DIR__ . '/../../vendor/autoload.php'); header('Content-Type: text/plain; charset=utf-8'); // create and run application $configurator = new \Venne\Config\Configurator(__DIR__ . '/../../app', $loader); $configurator->enableDebugger(); $configurator->enableLoader(); //\Nette\Diagnostics\Debugger::enable('development', __DIR__ . '/../../app/log'); /** @var \Doctrine\ORM\EntityManager $db */ $db = $configurator->createContainer()->entityManager; use V6ak\DB\Export\Exporter; $rules = (require __DIR__ . '/../../export/export-db.cfg.php'); $e = new Exporter($db); $exportResults = $e->exportByRules($rules, false); foreach ($exportResults->errors as $error) { echo "WARNING: {$error}\n"; } echo implode(";\n\n", $exportResults->data); }