Skip to content

Commit

Permalink
Fixed failing examples
Browse files Browse the repository at this point in the history
  • Loading branch information
norberttech committed Feb 18, 2024
1 parent 9eee94e commit 4120996
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 9 deletions.
File renamed without changes.
File renamed without changes.
30 changes: 30 additions & 0 deletions examples/topics/data_frame/overwrite/code.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

declare(strict_types=1);

use function Flow\ETL\Adapter\CSV\from_csv;
use function Flow\ETL\Adapter\CSV\to_csv;
use function Flow\ETL\DSL\df;
use function Flow\ETL\DSL\overwrite;

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

df()
->read(from_csv(__DIR__ . '/input/file.csv'))
->saveMode(overwrite())
->write(to_csv(__DIR__ . '/output/file.csv'))
->run();

df()
->read(from_csv(__DIR__ . '/output/file.csv'))
->saveMode(overwrite())
->drop('name')
->write(to_csv(__DIR__ . '/output/file.csv'))
->run();

// content of /output/file.csv:
// id
// 1
// 2
// 3
// 4
5 changes: 5 additions & 0 deletions examples/topics/data_frame/overwrite/input/file.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
id,name
1,"John Doe"
2,"Jane Doe"
3,"Tom Doe"
4,"Jerry Doe"
2 changes: 2 additions & 0 deletions examples/topics/data_frame/overwrite/output/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
18 changes: 9 additions & 9 deletions examples/topics/partitioning/partitioning/code.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,28 @@
]
))
->partitionBy(ref('color'), ref('sku'))
->write(to_csv(__DIR__ . '/output')) // do not provider extension, partitions are anyway written to separate folders
->write(to_csv(__DIR__ . '/output/products.csv'))
->run();

// output
// ├── color=blue
// │ ├── sku=PRODUCT01
// │ │ └── 65c7e9bc4460a568233195.csv
// │ │ └── products.csv
// │ └── sku=PRODUCT02
// │ └── 65c7e9bc446c2326068326.csv
// │ └── products.csv
// ├── color=green
// │ ├── sku=PRODUCT01
// │ │ └── 65c7e9bc44305321518126.csv
// │ │ └── products.csv
// │ ├── sku=PRODUCT02
// │ │ └── 65c7e9bc44421020940545.csv
// │ │ └── products.csv
// │ └── sku=PRODUCT03
// │ └── 65c7e9bc44515031584752.csv
// │ └── products.csv
// └── color=red
// ├── sku=PRODUCT01
// │ └── 65c7e9bc4386f958078278.csv
// │ └── products.csv
// ├── sku=PRODUCT02
// │ └── 65c7e9bc440fa083889144.csv
// │ └── products.csv
// └── sku=PRODUCT03
// └── 65c7e9bc44209401416287.csv
// └── products.csv
//
// 12 directories, 8 files

0 comments on commit 4120996

Please sign in to comment.