This commit is contained in:
James Cole
2017-02-15 15:18:52 +01:00
parent 47aa996b6b
commit cf2cd9680b
2 changed files with 19 additions and 6 deletions

View File

@@ -439,8 +439,9 @@ class CsvSetup implements SetupInterface
Log::debug('Now in getDataForColumnRoles()');
$config = $this->job->configuration;
$data = [
'columns' => [],
'columnCount' => 0,
'columns' => [],
'columnCount' => 0,
'columnHeaders' => [],
];
// show user column role configuration.
@@ -449,8 +450,13 @@ class CsvSetup implements SetupInterface
// create CSV reader.
$reader = Reader::createFromString($content);
$reader->setDelimiter($config['delimiter']);
$start = $config['has-headers'] ? 1 : 0;
$end = $start + config('csv.example_rows');
$start = $config['has-headers'] ? 1 : 0;
$end = $start + config('csv.example_rows');
$header = [];
if ($config['has-headers']) {
$header = $reader->fetchOne(0);
}
// collect example data in $data['columns']
Log::debug(sprintf('While %s is smaller than %d', $start, $end));
@@ -468,7 +474,8 @@ class CsvSetup implements SetupInterface
}
foreach ($row as $index => $value) {
$value = trim($value);
$value = trim($value);
$data['columnHeaders'][$index] = $header[$index] ?? '';
if (strlen($value) > 0) {
$data['columns'][$index][] = $value;
}