Skip to content
Search
Examples

Transformations

Description

Remove rows from your dataset based on conditions. Only rows matching the filter criteria are kept in the result. This is one of the most common operations for selecting a subset of data.

Documentation

Code

<?php

declare(strict_types=1);

use function Flow\ETL\DSL\{data_frame, from_array, ref, to_output};

require __DIR__ . '/vendor/autoload.php';

data_frame()
    ->read(from_array([
        ['id' => 1, 'name' => 'Alice', 'age' => 25, 'active' => true],
        ['id' => 2, 'name' => 'Bob', 'age' => 32, 'active' => false],
        ['id' => 3, 'name' => 'Charlie', 'age' => 28, 'active' => true],
        ['id' => 4, 'name' => 'Diana', 'age' => 35, 'active' => true],
        ['id' => 5, 'name' => 'Eve', 'age' => 22, 'active' => false],
    ]))
    ->collect()
    ->filter(ref('active')->isTrue())
    ->write(to_output(truncate: false))
    ->run();
Contributors

Built in the open.

Join us on GitHub
scroll back to top