mirror of
https://github.com/Llewellynvdm/php-ml.git
synced 2024-11-16 02:07:08 +00:00
change csv dataset constructor
This commit is contained in:
parent
a4ab370a48
commit
dea6972305
@ -26,8 +26,10 @@ class CsvDataset extends ArrayDataset
|
||||
throw DatasetException::missingFile(basename($filepath));
|
||||
}
|
||||
|
||||
if(false === $handle = fopen($filepath, 'r')) {
|
||||
throw DatasetException::cantOpenFile(basename($filepath));
|
||||
}
|
||||
$row = 0;
|
||||
if (($handle = fopen($filepath, 'r')) !== false) {
|
||||
while (($data = fgetcsv($handle, 1000, ',')) !== false) {
|
||||
++$row;
|
||||
if ($headingRow && $row == 1) {
|
||||
@ -37,8 +39,6 @@ class CsvDataset extends ArrayDataset
|
||||
$this->labels[] = $data[$features];
|
||||
}
|
||||
fclose($handle);
|
||||
} else {
|
||||
throw DatasetException::cantOpenFile(basename($filepath));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user