Skip to content

Commit 6adffb6

Browse files
committed
Merge pull request juanmf#1 from mruoss/patch-1
Use fgetcsv() to parse CSV
2 parents e0ae357 + 4b5c40d commit 6adffb6

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

Parsers/CsvSheetRecordParser.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,12 @@ public function __construct(
3131
$sheetFile, array $sheetRecordDefinition, $delimiter
3232
) {
3333
parent::__construct($sheetFile, $sheetRecordDefinition, $delimiter);
34-
$file = file($this->_sheetFile);
35-
foreach ($file as $index => $line) {
36-
$this->_sheet[$index] = explode($this->_delimiter, $line);
34+
if (($handle = fopen($sheetFile, "r")) !== FALSE) {
35+
$index = 0;
36+
while (($data = fgetcsv($handle, 0, $delimiter)) !== FALSE) {
37+
$this->_sheet[$index] = $data;
38+
$index++;
39+
}
3740
}
3841
$this->rewind();
3942
}

0 commit comments

Comments
 (0)