csv.asciidoc 1.8 KB

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