Read partitioned data after writing with overwrite mode. Each partition contains exactly one file with the latest data.
UNIFIED DATA PROCESSING FRAMEWORK
composer require flow-php/etl ~0.32.0 Extracts
Read from various data sources.
Transforms
Shape and optimize for your needs.
Loads
Store and secure in one of many available data sinks.
Examples:
Description
Documentation
Code
<?php
declare(strict_types=1);
use function Flow\ETL\Adapter\CSV\{from_csv, to_csv};
use function Flow\ETL\DSL\{data_frame, from_array, overwrite, ref, to_output};
require __DIR__ . '/vendor/autoload.php';
$outputPath = __DIR__ . '/output';
data_frame()
->read(from_array(
[
['id' => 1, 'color' => 'red', 'name' => 'Widget'],
['id' => 2, 'color' => 'blue', 'name' => 'Gadget'],
]
))
->partitionBy(ref('color'))
->mode(overwrite())
->write(to_csv($outputPath . '/products.csv'))
->run();
data_frame()
->read(from_csv($outputPath . '/color=*/*.csv'))
->write(to_output(truncate: false))
->run();