mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-02-25 18:45:27 -06:00
Fix some issues with semi-colon delimiters, see #1172
This commit is contained in:
parent
e066a6421c
commit
94f6bd34c7
@ -59,20 +59,19 @@ class Roles implements ConfigurationInterface
|
|||||||
$content = $this->repository->uploadFileContents($this->job);
|
$content = $this->repository->uploadFileContents($this->job);
|
||||||
$config = $this->getConfig();
|
$config = $this->getConfig();
|
||||||
$headers = [];
|
$headers = [];
|
||||||
$offset = 0;
|
|
||||||
// create CSV reader.
|
// create CSV reader.
|
||||||
$reader = Reader::createFromString($content);
|
$reader = Reader::createFromString($content);
|
||||||
$reader->setDelimiter($config['delimiter']);
|
$reader->setDelimiter($config['delimiter']);
|
||||||
|
|
||||||
if ($config['has-headers']) {
|
if ($config['has-headers']) {
|
||||||
$offset = 1;
|
|
||||||
// get headers:
|
// get headers:
|
||||||
$stmt = (new Statement)->limit(1)->offset(0);
|
$reader->setHeaderOffset(0);
|
||||||
$records = $stmt->process($reader);
|
$headers = $reader->getHeader();
|
||||||
$headers = $records->fetchOne();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// example rows:
|
// example rows:
|
||||||
$stmt = (new Statement)->limit(intval(config('csv.example_rows', 5)))->offset($offset);
|
$stmt = (new Statement)->limit(intval(config('csv.example_rows', 5)))->offset(0);
|
||||||
// set data:
|
// set data:
|
||||||
$roles = $this->getRoles();
|
$roles = $this->getRoles();
|
||||||
asort($roles);
|
asort($roles);
|
||||||
@ -85,6 +84,7 @@ class Roles implements ConfigurationInterface
|
|||||||
|
|
||||||
$records = $stmt->process($reader);
|
$records = $stmt->process($reader);
|
||||||
foreach ($records as $row) {
|
foreach ($records as $row) {
|
||||||
|
$row = array_values($row);
|
||||||
$row = $this->processSpecifics($row);
|
$row = $this->processSpecifics($row);
|
||||||
$count = count($row);
|
$count = count($row);
|
||||||
$this->data['total'] = $count > $this->data['total'] ? $count : $this->data['total'];
|
$this->data['total'] = $count > $this->data['total'] ? $count : $this->data['total'];
|
||||||
|
Loading…
Reference in New Issue
Block a user