Skip to content

Latest commit

 

History

History
48 lines (35 loc) · 2.25 KB

csv_reader_task.md

File metadata and controls

48 lines (35 loc) · 2.25 KB

CsvReaderTask

Reads a CSV file and iterate on each line, returning an array of key -> values. Skips empty lines.

Task reference

  • Service: CleverAge\ProcessBundle\Task\File\Csv\CsvReaderTask
  • Iterable task

Accepted inputs

Input is ignored

Possible outputs

array: foreach line, it will return a php array where key comes from headers and values are strings. Underlying method is fgetcsv.

Options

Code Type Required Default Description
file_path string X Path of the file to read from (relative to symfony root or absolute)
delimiter string ; CSV delimiter
enclosure string " CSV enclosure character
escape string \\ CSV escape character
headers array or null null Static list of CSV headers, without the option, it will be dynamically read from first input
mode string rb File open mode (see fopen mode parameter)
log_empty_lines bool false Log when the output is empty

Example

# Task configuration level
code:
  service: '@CleverAge\ProcessBundle\Task\File\Csv\CsvReaderTask'
  options:
    file_path: 'path/to/file.csv'
    delimiter: '{{ delimiter }}' ## delimiter is contextualized you must add -c delimiter:";" on console execute