Skip to content
Search
Examples

Columns

Description

rename_replace() strips or swaps a substring in every column name. A replacement that collides with an existing column fails - the schema keeps names unique.

Documentation

Code

<?php

declare(strict_types=1);

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

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

data_frame()
    ->read(from_array([
        ['order_id' => 1, 'order_status' => 'active'],
        ['order_id' => 2, 'order_status' => 'inactive'],
    ]))
    ->renameEach(rename_replace('order_', ''))
    ->collect()
    ->write(to_output(truncate: false))
    ->run();
Contributors

Built in the open.

Join us on GitHub
scroll back to top