<commit_before>[[csv-processor]]
=== CSV Processor
Extracts fields from CSV line out of a single text field within a document. Any empty field in CSV will be skipped.

[[csv-options]]
.CSV Options
[options="header"]
|======
| Name              | Required  | Default  | Description
| `field`           | yes       | -        | The field to extract data from
| `target_fields`   | yes       | -        | The array of fields to assign extracted values to
| `separator`       | no        | ,        | Separator used in CSV, has to be single character string
| `quote`           | no        | "        | Quote used in CSV, has to be single character string
| `ignore_missing`  | no        | `true`   | If `true` and `field` does not exist, the processor quietly exits without modifying the document
| `trim`            | no        | `false`  | Trim whitespaces in unquoted fields
include::common-options.asciidoc[]
|======

[source,js]
--------------------------------------------------
{
  "csv": {
    "field": "my_field",
    "target_fields": ["field1, field2"],
  }
}
--------------------------------------------------
// NOTCONSOLE

If the `trim` option is enabled then any whitespace in the beginning and in the end of each unquoted field will be trimmed.
For example with configuration above, a value of `A, B` will result in field `field2`
having value `{nbsp}B` (with space at the beginning). If `trim` is enabled `A, B` will result in field `field2`
having value `B` (no whitespace). Quoted fields will be left untouched.<commit_msg>[DOCS] Remove unneeded comma from CSV processor example (#51859)<commit_after>[[csv-processor]]
=== CSV Processor
Extracts fields from CSV line out of a single text field within a document. Any empty field in CSV will be skipped.

[[csv-options]]
.CSV Options
[options="header"]
|======
| Name              | Required  | Default  | Description
| `field`           | yes       | -        | The field to extract data from
| `target_fields`   | yes       | -        | The array of fields to assign extracted values to
| `separator`       | no        | ,        | Separator used in CSV, has to be single character string
| `quote`           | no        | "        | Quote used in CSV, has to be single character string
| `ignore_missing`  | no        | `true`   | If `true` and `field` does not exist, the processor quietly exits without modifying the document
| `trim`            | no        | `false`  | Trim whitespaces in unquoted fields
include::common-options.asciidoc[]
|======

[source,js]
--------------------------------------------------
{
  "csv": {
    "field": "my_field",
    "target_fields": ["field1, field2"]
  }
}
--------------------------------------------------
// NOTCONSOLE

If the `trim` option is enabled then any whitespace in the beginning and in the end of each unquoted field will be trimmed.
For example with configuration above, a value of `A, B` will result in field `field2`
having value `{nbsp}B` (with space at the beginning). If `trim` is enabled `A, B` will result in field `field2`
having value `B` (no whitespace). Quoted fields will be left untouched.
{'fraction_non_alphanumeric': 0.16442738323736406, 'fraction_numerical': 0.004158669225847729, 'mean_word_length': 2.2539021852237253, 'pattern_counts': {'":': 6, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3128776', 'n_tokens_mistral': 868, 'n_tokens_neox': 832, 'n_words': 365}