Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
norberttech authored Jan 10, 2025
1 parent c6373fc commit 0e18bb8
Showing 1 changed file with 10 additions and 51 deletions.
61 changes: 10 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,57 +17,16 @@ Supported PHP versions: [![PHP 8.2](https://img.shields.io/badge/php-~8.2-8892BF

---

## Flow PHP

Flow is the most advanced PHP ETL (Extract, Transform, Load) framework.

```php
<?php

declare(strict_types=1);

use function Flow\ETL\Adapter\Parquet\{from_parquet, to_parquet};
use function Flow\ETL\DSL\{data_frame, lit, ref, sum, to_output, overwrite};
use Flow\ETL\Filesystem\SaveMode;

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

data_frame()
->read(from_parquet(__DIR__ . '/orders_flow.parquet'))
->select('created_at', 'total_price', 'discount')
->withEntry('created_at', ref('created_at')->cast('date')->dateFormat('Y/m'))
->withEntry('revenue', ref('total_price')->minus(ref('discount')))
->select('created_at', 'revenue')
->groupBy('created_at')
->aggregate(sum(ref('revenue')))
->sortBy(ref('created_at')->desc())
->withEntry('daily_revenue', ref('revenue_sum')->round(lit(2))->numberFormat(lit(2)))
->drop('revenue_sum')
->write(to_output(truncate: false))
->withEntry('created_at', ref('created_at')->toDate('Y/m'))
->saveMode(overwrite())
->write(to_parquet(__DIR__ . '/daily_revenue.parquet'))
->run();
```

```console
$ php daily_revenue.php
+------------+---------------+
| created_at | daily_revenue |
+------------+---------------+
| 2023/10 | 206,669.74 |
| 2023/09 | 227,647.47 |
| 2023/08 | 237,027.31 |
| 2023/07 | 240,111.05 |
| 2023/06 | 225,536.35 |
| 2023/05 | 234,624.74 |
| 2023/04 | 231,472.05 |
| 2023/03 | 231,697.36 |
| 2023/02 | 211,048.97 |
| 2023/01 | 225,539.81 |
+------------+---------------+
10 rows
```
## Usage Example

The most up-to-date examples are available at https://flow-php.com

- [DataFrame](https://flow-php.com/documentation/example/data_frame/data_frame/#example)
- [Reading data from Array](https://flow-php.com/documentation/example/data_reading/array/#example)
- [Reading data from CSV](https://flow-php.com/documentation/example/data_reading/csv/#example)
- [Joins](https://flow-php.com/documentation/example/join/join/#example)
- [Aggregatios](https://flow-php.com/documentation/example/aggregations/group_by/#example)
- and many more...

## Community Contributions

Expand Down

0 comments on commit 0e18bb8

Please sign in to comment.