ziyodulloxon / simple-csv
Simple CSV reader/writer
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/ziyodulloxon/simple-csv
Requires
- php: ^8.0
Requires (Dev)
- phpunit/phpunit: ^9.0
This package is auto-updated.
Last update: 2025-10-03 08:33:29 UTC
README
Basic Usage
$reader = new \Ziyodulloxon\SimpleCsv\Reader("./path/to/file.csv"); $rows = $reader->read(); foreach ($rows as $row) { var_dump($row); }
Output:
[
0 => 111,
1 => "+79991234567",
2 => "John Smith",
],
[
0 => 112,
1 => "+79881234568",
2 => "Jane Doe",
],
[
0 => 49329,
1 => "+79771234569",
2 => "Walter White",
]
Using associateWithHeaders() to Use Headers as Keys
$reader = new \Ziyodulloxon\SimpleCsv\Reader("./path/to/file.csv"); $rows = $reader->associateWithHeaders()->read(); foreach ($rows as $row) { var_dump($row); }
Output:
[
"id_client" => 111,
"phone" => "+79991234567",
"name" => "John Smith",
],
[
"id_client" => 112,
"phone" => "+79881234568",
"name" => "Jane Doe",
],
[
"id_client" => 49329,
"phone" => "+79771234569",
"name" => "Walter White",
]
Using batchRead() for Large Files
$reader = new \Ziyodulloxon\SimpleCsv\Reader("./path/to/file.csv"); //$iterable is an instance of \Generator $iterable = $reader->associateWithHeaders()->batchRead(1); foreach ($iterable as $item) { var_dump($item); }
Output:
Same as above, but with lower memory usage.
