1
0

csv.asciidoc 1.7 KB

1234567891011121314151617181920212223242526272829303132333435
  1. [[csv-processor]]
  2. === CSV Processor
  3. Extracts fields from CSV line out of a single text field within a document. Any empty field in CSV will be skipped.
  4. [[csv-options]]
  5. .CSV Options
  6. [options="header"]
  7. |======
  8. | Name | Required | Default | Description
  9. | `field` | yes | - | The field to extract data from
  10. | `target_fields` | yes | - | The array of fields to assign extracted values to
  11. | `separator` | no | , | Separator used in CSV, has to be single character string
  12. | `quote` | no | " | Quote used in CSV, has to be single character string
  13. | `ignore_missing` | no | `true` | If `true` and `field` does not exist, the processor quietly exits without modifying the document
  14. | `trim` | no | `false` | Trim whitespaces in unquoted fields
  15. | `empty_value` | no | - | Value used to fill empty fields, empty fields will be skipped if this is not provided.
  16. Empty field is one with no value (2 consecutive separators) or empty quotes (`""`)
  17. include::common-options.asciidoc[]
  18. |======
  19. [source,js]
  20. --------------------------------------------------
  21. {
  22. "csv": {
  23. "field": "my_field",
  24. "target_fields": ["field1", "field2"]
  25. }
  26. }
  27. --------------------------------------------------
  28. // NOTCONSOLE
  29. If the `trim` option is enabled then any whitespace in the beginning and in the end of each unquoted field will be trimmed.
  30. For example with configuration above, a value of `A, B` will result in field `field2`
  31. having value `{nbsp}B` (with space at the beginning). If `trim` is enabled `A, B` will result in field `field2`
  32. having value `B` (no whitespace). Quoted fields will be left untouched.