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 - Operations
Aggregation/Grouping - Simple grouping (simple-grouping)

The simple-grouping operation groups items based on a common key, useful for data aggregation (e.g., grouping customers by city). It collects items in memory, then outputs a single GroupedItem with an iterator for the grouped data.

Options

  • grouping_key: An array of keys to use for grouping. The values of these keys will be combined to create a unique identifier for each group.
  • group_identifier: (Optional) An array of keys to use for identifying individual items within a group. If specified, only the last item with a given identifier will be kept in the group.

Example

Here’s an example of how to use the simple-grouping operation to group a list of customers by their city.

Input Data (a sequence of items):

[
  { "name": "John Doe", "city": "New York" },
  { "name": "Jane Doe", "city": "New York" },
  { "name": "Peter Jones", "city": "London" }
]

YAML Configuration:

chain:
  - operation: simple-grouping
    options:
      grouping_key: ["city"]

  - operation: rule-transformer
    options:
      # Rules to process the grouped data.
      # The input to this operation will be an iterator of groups.
      # Each group will be an array of customers.

Output:

The rule-transformer will receive an iterator with two groups:

  • Group 1 (New York):
    [
      { "name": "John Doe", "city": "New York" },
      { "name": "Jane Doe", "city": "New York" }
    ]
    
  • Group 2 (London):
    [
      { "name": "Peter Jones", "city": "London" }
    ]
    

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)