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
Load - CSV File(csv-write)

The csv-write operation writes data to a CSV file. It expects DataItem objects with associative arrays; keys become CSV headers (if has_headers is true). All DataItem objects should have consistent keys for a uniform CSV structure.

Options

  • file: The path to the CSV file to write to.
  • delimiter: (Optional) The character used to separate fields in the CSV file. Defaults to ;.
  • enclosure: (Optional) The character used to enclose fields in the CSV file. Defaults to ".
  • escape: (Optional) The character used to escape special characters in the CSV file. Defaults to \.
  • has_headers: (Optional) A boolean indicating whether to write a header row to the CSV file. Defaults to true.

Example

Here’s an example of how to use the csv-write operation to save transformed data to a new CSV file:

chain:
  - operation: extract-csv
    options:
      path: /path/to/input.csv

  - operation: rule-transformer
    options:
      # Rules to transform the CSV data.
      columns:
        FullName:
          rules:
            - implode:
                values:
                  - { get: { field: "FirstName" } }
                  - { get: { field: "LastName" } }
                with: " "

  - operation: csv-write
    options:
      file: /path/to/output.csv
      delimiter: ","
      has_headers: true

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)