<commit_before>defmodule CSV.Encoding.Encoder do
  use CSV.Defaults
  alias CSV.Encode

  @moduledoc ~S"""
  The Encoder CSV module takes a table stream and transforms it into RFC 4180
  compliant stream of lines for writing to a CSV File or other IO.
  """

  @doc """
  Encode a table stream into a stream of RFC 4180 compliant CSV lines for
  writing to a file or other IO.

  ## Options

  These are the options:

    * `:separator`        – The separator character to use, defaults to `?,`.
      Must be a codepoint (syntax: ? + your separator).
    * `:escape_character` – The escape character to use, defaults to `?"`.
      Must be a codepoint (syntax: ? + your escape character).
    * `:delimiter`        – The delimiter token to use, defaults to `\"\\r\\n\"`.
    * `:headers`          – When set to `true`, uses the keys of the first map as
      the first element in the stream. All subsequent elements are the values
      of the maps. When set to a list, will use the given list as the first
      element in the stream and order all subsequent elements using that list.
      When set to `false` (default), will use the raw inputs as elements.
      When set to anything but `false`, all elements in the input stream are
      assumed to be maps.
    * `:escape_formulas`   – Escape formulas to prevent
      [CSV Injection](https://owasp.org/www-community/attacks/CSV_Injection).

  ## Examples
<commit_msg>Improve documentation on encoding headers<commit_after>defmodule CSV.Encoding.Encoder do
  use CSV.Defaults
  alias CSV.Encode

  @moduledoc ~S"""
  The Encoder CSV module takes a table stream and transforms it into RFC 4180
  compliant stream of lines for writing to a CSV File or other IO.
  """

  @doc """
  Encode a table stream into a stream of RFC 4180 compliant CSV lines for
  writing to a file or other IO.

  ## Options

  These are the options:

    * `:separator`        – The separator character to use, defaults to `?,`.
      Must be a codepoint (syntax: ? + your separator).
    * `:escape_character` – The escape character to use, defaults to `?"`.
      Must be a codepoint (syntax: ? + your escape character).
    * `:delimiter`        – The delimiter token to use, defaults to `\"\\r\\n\"`.
    * `:headers`
        * When set to `false` (default), will use the raw inputs as elements.  When set to anything but `false`, all elements in the input stream are assumed to be maps.
        * When set to `true`, uses the keys of the first map as the first
    element in the stream. All subsequent elements are the values of the maps.
        * When set to a list, will use the given list as the first element
        in the stream and order all subsequent elements using that list.
        * When set to a keyword list, will use the keys of the
        keyword list to match the keys of the data, and the values of the
        keyword list to be the values in the first row of the output.
    * `:escape_formulas`   – Escape formulas to prevent
      [CSV Injection](https://owasp.org/www-community/attacks/CSV_Injection).

  ## Examples

{'fraction_non_alphanumeric': 0.07789678675754626, 'fraction_numerical': 0.00519311911716975, 'mean_word_length': 2.8143564356435644, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2459461', 'n_tokens_mistral': 886, 'n_tokens_neox': 825, 'n_words': 438}