Read data from an Excel file (XLSX or ODS).
function from_excel(
string|Path $path
):
Read from various data sources.
Shape and optimize for your needs.
Store and secure in one of many available data sinks.
Read data from an Excel file (XLSX or ODS).
function from_excel(
string|Path $path
):
composer.json
{
"name": "flow-php/examples",
"description": "Flow PHP - Examples",
"license": "MIT",
"type": "library",
"require": {
"flow-php/etl": "1.x-dev",
"flow-php/etl-adapter-excel": "1.x-dev"
},
"minimum-stability": "dev",
"prefer-stable": true
}
code.php
<?php
declare(strict_types=1);
use function Flow\ETL\Adapter\Excel\DSL\from_excel;
use function Flow\ETL\DSL\{data_frame, to_stream};
require __DIR__ . '/vendor/autoload.php';
data_frame()
->read(from_excel(
__DIR__ . '/input/dataset.xlsx',
))
->collect()
->write(to_stream(__DIR__ . '/output.txt', truncate: false))
->run();
+----+---------+-------------------+
| id | name | email |
+----+---------+-------------------+
| 1 | user-01 | [email protected] |
| 2 | user-02 | [email protected] |
| 3 | user-03 | [email protected] |
| 4 | user-04 | [email protected] |
| 5 | user-05 | [email protected] |
| 6 | user-06 | [email protected] |
| 7 | user-07 | [email protected] |
| 8 | user-08 | [email protected] |
| 9 | user-09 | [email protected] |
+----+---------+-------------------+
9 rows