Logo of php-etl
Getting Started
🐘 Standalone šŸŽµ Symfony 🦢 Sylius
Core Concepts
The Concept Execution Context Item Types Custom Operations Glossary FAQ
ā›“ļø Operations
Building Blocks
Split Merge Repeat Safe
Extract
File Finder CSV JSON
Transform
External File Processor Filter Data Rule Transformer Split Item HTTP Client Log Callback
Aggregation
Simple Grouping
Load
CSV JSON
šŸ§‘ā€šŸ³ Cookbook
Without Context
Grouping / Aggregation Filtering Splitting/Forking Making your chains configurable Complex data to csv / Flatten Data Api to CSV N°1 Api to CSV N°2 Sub chains
With Context
Api to CSV Import external file
Custom Operations

PHP-ETL - Cook Books
With Context - Import External File

With Context - Import External File

The ETL can be used to fetch files from another filesystem and process them using the ETL. Files will be moved into processing and processed directories as the ETL runs.

We will use the ExternalFileFinderOperation to find the files. And use the ExternalFileProcessorOperation to copy the files to the context of the ETL execution.

The file finder will use a directory that we will add to the context at the beginning of the execution.

We will also need to provide the finder with a regex as chain input so that it can find all the files.

  find-file1:
    operation: external-file-finder-local
    options:
      directory: "@context['dir']"

  process-new-file1:
    operation: external-file-processor
    options: []

🐘 Standalone

$options = [
    // ...
    'dir' => $dir,
];

$chainProcessor->process(
    new ArrayIterator(['/^file[0-9]\.csv$/']),
    $options
);

šŸŽµ Symfony

./bin/console etl:execute myetl "['/^file[0-9]\.csv$/']" "{'dir': '/var/import'}"

Complete Code

chain:
  find-file1:
    operation: external-file-finder-local
    options:
      directory: "@context['dir']"

  process-new-file1:
    operation: external-file-processor
    options: []

  read-file:
    operation: csv-read
    options: [] 

  write-new-file:
    operation: csv-write
    options:
      file: "output.csv"

  process-finalized-file1:
    operation: external-file-processor
    options: []

Network

GitHub Repo Issues Good First Issues

Help Preserve This Project

Support for the continued development of php ETL. I maintain this project in my free time.

Support
Free & Open Source (MIT)