csv.asciidoc 1.5 KB

123456789101112131415161718192021222324252627282930313233
  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. include::common-options.asciidoc[]
  16. |======
  17. [source,js]
  18. --------------------------------------------------
  19. {
  20. "csv": {
  21. "field": "my_field",
  22. "target_fields": ["field1, field2"],
  23. }
  24. }
  25. --------------------------------------------------
  26. // NOTCONSOLE
  27. If the `trim` option is enabled then any whitespace in the beginning and in the end of each unquoted field will be trimmed.
  28. For example with configuration above, a value of `A, B` will result in field `field2`
  29. having value `{nbsp}B` (with space at the beginning). If `trim` is enabled `A, B` will result in field `field2`
  30. having value `B` (no whitespace). Quoted fields will be left untouched.