Files
Reseaux-de-neurones-artific…/app/Services/CsvReader.php
Matthias Guillitte f0e7be4476
Some checks failed
linter / quality (push) Failing after 18s
tests / ci (8.4) (push) Failing after 10s
tests / ci (8.5) (push) Failing after 11s
Gradient descent training + Added all dataset + graphs improvements
2026-03-13 22:06:08 +01:00

31 lines
635 B
PHP

<?php
namespace App\Services;
class CsvReader {
private $file;
// private array $headers;
public array $lines = [];
public function __construct(
public string $filename,
)
{
$this->file = fopen($filename, "r");
if (!$this->file) {
throw new \RuntimeException("Failed to open file: " . $filename);
}
// $this->headers = $this->readNextLine();
}
public function readNextLine(): ?array
{
if (($data = fgetcsv($this->file, 1000, ",")) !== FALSE) {
return $data;
}
return null; // End of file or error
}
}