kentreez / easy-file-reader
Simple way for reading .txt, .msv, .xls, .xlsx
dev-main
2022-07-31 18:13 UTC
Requires
- phpoffice/phpspreadsheet: ^1.24
This package is auto-updated.
Last update: 2025-07-29 02:10:32 UTC
README
Reading each lines data from file (.txt, .csv, .xls, .xlsx). The library using PHP Generator then input file will be read line by line to avoid store total file data in memory.
*** Caution ***
Because of using Generator for iterate over input file's rows. DO NOT BREAK the loop while iterate over file's rows it will cause unexpected behavior.
Usage:
<?php
use Kentreez\EasyFileReader\EasyFileReader;
require_once 'vendor/autoload.php';
$easy = EasyFileReader::Read('example.xlsx');
// count all rows
$easy->count();
// iterate over rows in input file
foreach ($easy->rows() as $rows) {
print_r($rows);
}
// if we interest only first column of each row then
foreach ($easy->firstColumns() as $str) {
echo $str . PHP_EOL;
}
?>