### NimbleCSV Dumping Examples Source: https://hexdocs.pm/nimble_csv/index.html Demonstrates dumping data into iodata and streams using defined parsers. ```APIDOC ## NimbleCSV Dumping ### Description NimbleCSV can dump enumerable data into iodata or streams, converting rows back into CSV format. ### Method `MyParser.dump_to_iodata/1`, `MyParser.dump_to_stream/1` ### Endpoint N/A (Module functions) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example (Dump to Iodata) ```elixir MyParser.dump_to_iodata([~w(name age), ~w(mary 28)]) # Expected output: "name\tage\nmary\t28\n" ``` ### Request Example (Dump to Stream) ```elixir MyParser.dump_to_stream([~w(name age), ~w(mary 28)]) # Expected output: #Stream<[ # enum: [["name", "age"], ["mary", "28"]], # funs: [#Function<47.127921642/1 in Stream.map/2>] #]> ``` ### Response `dump_to_iodata/1` returns iodata. `dump_to_stream/1` returns a stream that emits rows as iodata. ``` -------------------------------- ### NimbleCSV Parsing Examples Source: https://hexdocs.pm/nimble_csv/index.html Demonstrates parsing CSV data from strings and streams using defined parsers. ```APIDOC ## NimbleCSV Parsing ### Description NimbleCSV provides functions to parse CSV data from strings, enumerables, and streams. It's designed to be efficient by working with binary references. ### Method `MyParser.parse_string/1`, `MyParser.parse_stream/1`, `NimbleCSV.RFC4180.parse_string/1` ### Endpoint N/A (Module functions) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example (String Parsing) ```elixir MyParser.parse_string("name\tage\njohn\t27") # Expected output: [["john", "27"]] "name\tage\njohn\t27" |> MyParser.parse_string() |> Enum.map(fn [name, age] -> %{name: name, age: String.to_integer(age)} end) # Expected output: [%{name: "john", age: 27}] ``` ### Request Example (Stream Parsing) ```elixir "path/to/csv/file" |> File.stream!(read_ahead: 100_000) |> MyParser.parse_stream() |> Stream.map(fn [name, age] -> %{name: :binary.copy(name), age: String.to_integer(age)} end) |> Stream.run() ``` ### Request Example (RFC4180 Default Parser) ```elixir alias NimbleCSV.RFC4180, as: CSV CSV.parse_string("name,age\njohn,27") # Expected output: [["john", "27"]] ``` ### Response Returns a list of rows, where each row is a list of binary strings representing the CSV fields. For streams, it returns a stream of rows. ``` -------------------------------- ### Parse CSV String with Custom Parser Source: https://hexdocs.pm/nimble_csv/NimbleCSV.html Parse a CSV string using a previously defined custom parser. This example shows basic parsing without header handling. ```nimble_csv iex> MyParser.parse_string("name\tage\njohn\t27") [["john","27"]] ``` -------------------------------- ### Configure CSV Formula Escaping Source: https://hexdocs.pm/nimble_csv/NimbleCSV.html Configures how CSV values that might be interpreted as formulas are escaped to prevent CSV injection. This example follows OWASP recommendations by prefixing potentially problematic values with a tab or single quote. ```elixir escape_formula: %{["@", "+", "-", "=", "\t", "\r"] => "'"} ``` -------------------------------- ### define(module, options) Source: https://hexdocs.pm/nimble_csv/index.html Defines a new parser/dumper module with specific configuration. ```APIDOC ## define(module, options) ### Description Defines a new CSV parser/dumper module. This should be invoked at the top of files. ### Parameters #### Arguments - **module** (atom) - Required - The name of the module to define. - **options** (keyword) - Required - Configuration for parsing and dumping. #### Parsing Options - **:escape** (string) - Optional - CSV escape character, defaults to "\"". - **:encoding** (string) - Optional - Converts data from encoding to UTF-8. - **:separator** (string/list) - Optional - CSV separator(s). - **:newlines** (list) - Optional - List of entries considered newlines. - **:trim_bom** (boolean) - Optional - Automatically trims BOM when parsing strings. #### Dumping Options - **:line_separator** (string) - Optional - CSV line separator, defaults to "\n". - **:dump_bom** (boolean) - Optional - Includes BOM in the dumped document. - **:escape_formula** (map) - Optional - Configuration for escaping formula prefixes. ``` -------------------------------- ### define/2 Source: https://hexdocs.pm/nimble_csv/NimbleCSV.html Defines a new parser/dumper module with specific configuration options. ```APIDOC ## define(module, options) ### Description Defines a new parser/dumper module at the top level of your file. ### Parameters - **module** (atom) - Required - The name of the module to define. - **options** (keyword) - Required - Configuration options such as :separator and :escape. ### Request Example NimbleCSV.define(MyParser, separator: "\t", escape: "\"") ``` -------------------------------- ### NimbleCSV Binary References Source: https://hexdocs.pm/nimble_csv/index.html Explains the use of binary references in NimbleCSV and the necessity of copying data. ```APIDOC ## NimbleCSV Binary References ### Description NimbleCSV leverages binary references for performance. Parsed fields reference the original binary data. If the data needs to persist or be sent to another process, it must be explicitly copied using `:binary.copy/1` to avoid issues with the original binary being garbage collected or modified. ### Method N/A (Concept explanation) ### Endpoint N/A ### Parameters None ### Request Example ```elixir # Example showing the need for :binary.copy "one,two,three" |> NimbleCSV.RFC4180.parse_string() |> List.first() # This is a list of binary references |> Enum.map(&:binary.copy/1) # Explicitly copy each field # Expected output: ["one", "two", "three"] (as new binaries) ``` ### Response N/A (Conceptual explanation) ``` -------------------------------- ### NimbleCSV Module Overview Source: https://hexdocs.pm/nimble_csv/api-reference.html Overview of the main NimbleCSV module and its sub-modules for parsing and dumping CSV data. ```APIDOC ## NimbleCSV ### Description NimbleCSV is a small and fast parsing and dumping library for CSV files. ### Modules - **NimbleCSV.ParseError**: Exception raised during parsing errors. - **NimbleCSV.RFC4180**: A CSV parser that uses comma as separator and double-quotes as escape according to RFC4180. - **NimbleCSV.Spreadsheet**: A parser with spreadsheet friendly settings. ``` -------------------------------- ### Parse CSV from a String (Eager) Source: https://hexdocs.pm/nimble_csv/NimbleCSV.html Eagerly parses CSV data from a binary string into a list of rows. Raises `NimbleCSV.ParseError` for invalid CSV. Options like `:skip_headers` can be provided. ```elixir @callback parse_string(binary()) :: [[binary()]] ``` ```elixir @callback parse_string(binary(), opts :: keyword()) :: [[binary()]] ``` -------------------------------- ### dump_to_iodata/1 Source: https://hexdocs.pm/nimble_csv/NimbleCSV.html Eagerly dumps an enumerable into iodata. ```APIDOC ## dump_to_iodata(rows) ### Description Converts an enumerable of rows into iodata format. ### Parameters - **rows** (Enumerable.t) - Required - The data to dump. ### Response - **iodata** (iodata) - The resulting iodata representation. ``` -------------------------------- ### Callback: dump_to_iodata/1 Source: https://hexdocs.pm/nimble_csv/index.html Eagerly dumps an enumerable into iodata. ```elixir @callback dump_to_iodata(rows :: Enumerable.t()) :: iodata() ``` -------------------------------- ### Dump data to iodata or streams Source: https://hexdocs.pm/nimble_csv/index.html Convert enumerables into iodata or streams for efficient output. ```elixir iex> IO.iodata_to_binary MyParser.dump_to_iodata([~w(name age), ~w(mary 28)]) "name\tage\nmary\t28\n" iex> MyParser.dump_to_stream([~w(name age), ~w(mary 28)]) #Stream<[ enum: [["name", "age"], ["mary", "28"]], funs: [#Function<47.127921642/1 in Stream.map/2>] ]> ``` -------------------------------- ### parse_string/2 Callback Source: https://hexdocs.pm/nimble_csv/index.html Defines the callback for eagerly parsing a CSV string with options. ```elixir @callback parse_string(binary(), opts :: keyword()) :: [[binary()]] ``` -------------------------------- ### Utility Functions Source: https://hexdocs.pm/nimble_csv/index.html Helper functions for stream manipulation. ```APIDOC ## to_line_stream(stream) ### Description Lazily convert a stream of arbitrarily chunked binaries to a line-oriented one. Useful when a CSV cannot be streamed in a line-oriented fashion from its source. ### Parameters #### Arguments - **stream** (Enumerable.t()) - Required - The stream to convert. ``` -------------------------------- ### Dump Data to Iodata Source: https://hexdocs.pm/nimble_csv/NimbleCSV.html Dump an enumerable of rows into iodata format. This is an eager operation that returns the complete iodata structure. ```nimble_csv iex> IO.iodata_to_binary MyParser.dump_to_iodata([~w(name age), ~w(mary 28)]) "name\tage\nmary\t28\n" ``` -------------------------------- ### define/2 Source: https://hexdocs.pm/nimble_csv/NimbleCSV.html Defines a new CSV parser/dumper module with specified options. Typically used at the top level of a file. ```APIDOC ## POST /define_parser_dumper ### Description Defines a new parser/dumper. Calling this function defines a CSV module. Therefore, `define/2` is typically invoked at the top of your files and not inside functions. Placing it inside a function would cause the same module to be defined multiple times, one time per invocation, leading your code to emit warnings and slowing down execution. ### Method POST ### Endpoint /define_parser_dumper ### Parameters #### Request Body - **module** (module()) - Required - The module to define. - **options** (keyword()) - Required - Options for the parser/dumper. - **Parsing Options**: - **:escape** (string()) - The CSV escape character, defaults to `"\""`. - **:encoding** (string()) - Converts the given data from encoding to UTF-8. - **:separator** (string() | list(string())) - The CSV separators, defaults to `","`. It can be a string or a list of strings. If a list is given, the first entry is used for dumping. - **:newlines** (list(string())) - The list of entries to be considered newlines when parsing, defaults to `["\r\n", "\n"]`. - **:trim_bom** (boolean()) - Automatically trims BOM (byte-order marker) when parsing string. Note the BOM is not trimmed for enumerables or streams. - **Dumping Options**: - **:escape** (string()) - The CSV escape character, defaults to `"\""`. - **:encoding** (string()) - Converts the given data from UTF-8 to the given encoding. - **:separator** (string()) - The CSV separator character, defaults to `","`. - **:line_separator** (string()) - The CSV line separator character, defaults to `"\n"`. - **:dump_bom** (boolean()) - Includes BOM (byte order marker) in the dumped document. - **:reserved** (list(string())) - The list of characters to be escaped, defaults to the `:separator`, `:newlines`, and `:escape` characters above. - **:escape_formula** (map() | nil) - The formula prefix(es) and formula escape sequence, defaults to `nil`. Example: `%{["@", "+", "-", "=", "\t", "\r"] => "'"}`. ### Request Example ```json { "module": "MyCSVParser", "options": { "separator": ";", "skip_headers": false, "escape_formula": { "@": "'" } } } ``` ### Response #### Success Response (200) - **message** (string()) - Confirmation message that the module was defined. #### Response Example ```json { "message": "Module MyCSVParser defined successfully." } ``` ``` -------------------------------- ### parse_string/2 Source: https://hexdocs.pm/nimble_csv/NimbleCSV.html Eagerly parses CSV data from a binary string with specified options, returning a list of rows. Raises NimbleCSV.ParseError for invalid CSV. ```APIDOC ## POST /parse_string_with_opts ### Description Eagerly parses CSV from a string with options and returns a list of rows. Raises `NimbleCSV.ParseError` for an invalid CSV. ### Method POST ### Endpoint /parse_string_with_opts ### Parameters #### Request Body - **binary** (binary()) - Required - The CSV string to parse. - **opts** (keyword()) - Optional - Options for parsing. - **:skip_headers** (boolean()) - When `true`, skips headers. Defaults to `true`. Set it to `false` to keep headers or when the CSV has no headers. ### Request Example ```json { "binary": "header1,header2\nvalue1,value2", "opts": { "skip_headers": false } } ``` ### Response #### Success Response (200) - **rows** (list(list(binary()))) - A list of parsed CSV rows. #### Response Example ```json { "rows": [["header1", "header2"], ["value1", "value2"]] } ``` ``` -------------------------------- ### parse_string/1 Source: https://hexdocs.pm/nimble_csv/NimbleCSV.html Eagerly parses CSV data from a binary string and returns a list of rows. This is a convenience function that calls parse_string/2 with default options. ```APIDOC ## POST /parse_string ### Description Eagerly parses CSV from a string and returns a list of rows. Raises `NimbleCSV.ParseError` for an invalid CSV. ### Method POST ### Endpoint /parse_string ### Parameters #### Request Body - **binary** (binary()) - Required - The CSV string to parse. ### Request Example ```json { "binary": "header1,header2\nvalue1,value2" } ``` ### Response #### Success Response (200) - **rows** (list(list(binary()))) - A list of parsed CSV rows. #### Response Example ```json { "rows": [["header1", "header2"], ["value1", "value2"]] } ``` ``` -------------------------------- ### Define a Custom CSV Parser/Dumper Module Source: https://hexdocs.pm/nimble_csv/NimbleCSV.html Defines a new module for CSV parsing and dumping. Typically used at the top of files, not within functions, to avoid redefinition warnings. Accepts options for parsing and dumping behavior. ```elixir define(module, options) ``` -------------------------------- ### parse_string/1 Callback Source: https://hexdocs.pm/nimble_csv/index.html Defines the callback for eagerly parsing a CSV string into a list of rows. ```elixir @callback parse_string(binary()) :: [[binary()]] ``` -------------------------------- ### Convert Stream to Line-Oriented Stream Source: https://hexdocs.pm/nimble_csv/NimbleCSV.html Lazily converts a stream of arbitrarily chunked binaries into a line-oriented stream. Useful when the CSV source is not inherently line-based. ```elixir @callback to_line_stream(stream :: Enumerable.t()) :: Enumerable.t() ``` -------------------------------- ### Callback: parse_enumerable/1 Source: https://hexdocs.pm/nimble_csv/index.html Eagerly parses CSV from an enumerable. ```elixir @callback parse_enumerable(enum :: Enumerable.t()) :: [[binary()]] ``` ```elixir @callback parse_enumerable(enum :: Enumerable.t(), opts :: keyword()) :: [[binary()]] ``` -------------------------------- ### Callback: dump_to_stream/1 Source: https://hexdocs.pm/nimble_csv/index.html Lazily dumps an enumerable to a stream of iodata. ```elixir @callback dump_to_stream(rows :: Enumerable.t()) :: Enumerable.t() ``` -------------------------------- ### Binary references explanation Source: https://hexdocs.pm/nimble_csv/index.html NimbleCSV returns binary references to the original row for performance. Copy data if it must persist outside the parsing process. ```elixir one,two,three,four,five ``` -------------------------------- ### to_line_stream/1 Source: https://hexdocs.pm/nimble_csv/NimbleCSV.html Lazily converts a stream of arbitrarily chunked binaries into a line-oriented stream, suitable for CSV parsing. ```APIDOC ## POST /to_line_stream ### Description Lazily converts a stream of arbitrarily chunked binaries to a line-oriented one. This is useful for places where a CSV cannot be streamed in a line-oriented fashion from its source. ### Method POST ### Endpoint /to_line_stream ### Parameters #### Request Body - **stream** (Enumerable.t()) - Required - The stream to convert. ### Request Example ```json { "stream": ["chunk1\nchunk2"] } ``` ### Response #### Success Response (200) - **line_stream** (Enumerable.t()) - A line-oriented stream. #### Response Example ```json { "line_stream": ["line1", "line2"] } ``` ``` -------------------------------- ### Dump Data to Stream Source: https://hexdocs.pm/nimble_csv/NimbleCSV.html Lazily dump an enumerable of rows to a stream. This is useful for processing large datasets without loading everything into memory. ```nimble_csv iex> MyParser.dump_to_stream([~w(name age), ~w(mary 28)]) #Stream<[ enum: [["name", "age"], ["mary", "28"]], funs: [#Function<47.127921642/1 in Stream.map/2>] ]> ``` -------------------------------- ### NimbleCSV Spreadsheet Parser Source: https://hexdocs.pm/nimble_csv/NimbleCSV.Spreadsheet.html This section details the functions available in NimbleCSV.Spreadsheet for parsing CSV data with spreadsheet-specific settings. ```APIDOC ## NimbleCSV.Spreadsheet (NimbleCSV v1.3.0) A parser with spreadsheet friendly settings. The parser uses tab as separator and double-quotes as escape, as required by common spreadsheet software such as Excel, Numbers and OpenOffice. It's encoded in UTF-16 little-endian with a byte-order BOM. Such files should still be saved with the `.csv` extension. ### Functions - `dump_to_iodata(enumerable)`: Callback implementation for `NimbleCSV.dump_to_iodata/1`. - `dump_to_stream(enumerable)`: Callback implementation for `NimbleCSV.dump_to_stream/1`. - `parse_enumerable(enumerable, opts \\ [])`: Callback implementation for `NimbleCSV.parse_enumerable/2`. - `parse_stream(stream, opts \\ [])`: Callback implementation for `NimbleCSV.parse_stream/2`. - `parse_string(string, opts \\ [])`: Callback implementation for `NimbleCSV.parse_string/2`. - `to_line_stream(stream)`: Callback implementation for `NimbleCSV.to_line_stream/1`. ## dump_to_iodata(enumerable) Callback implementation for `NimbleCSV.dump_to_iodata/1`. ## dump_to_stream(enumerable) Callback implementation for `NimbleCSV.dump_to_stream/1`. ## parse_enumerable(enumerable, opts \\ []) Callback implementation for `NimbleCSV.parse_enumerable/2`. ## parse_stream(stream, opts \\ []) Callback implementation for `NimbleCSV.parse_stream/2`. ## parse_string(string, opts \\ []) Callback implementation for `NimbleCSV.parse_string/2`. ## to_line_stream(stream) Callback implementation for `NimbleCSV.to_line_stream/1`. ``` -------------------------------- ### Define a Custom CSV Parser Source: https://hexdocs.pm/nimble_csv/NimbleCSV.html Define a custom parser module with specific separator and escape characters. This sets up a reusable parser for your CSV data. ```nimble_csv NimbleCSV.define(MyParser, separator: "\t", escape: "\"") ``` -------------------------------- ### parse_string/2 Source: https://hexdocs.pm/nimble_csv/NimbleCSV.html Eagerly parses CSV data from a string into a list of rows. ```APIDOC ## parse_string(binary, opts) ### Description Parses a CSV string into a list of rows. ### Parameters - **binary** (string) - Required - The CSV data string. - **opts** (keyword) - Optional - Parsing options. ### Response - **rows** (list) - A list of lists containing the parsed fields. ``` -------------------------------- ### NimbleCSV.ParseError Exception Source: https://hexdocs.pm/nimble_csv/NimbleCSV.ParseError.html Information about the NimbleCSV.ParseError exception, which is raised during CSV parsing operations. ```APIDOC ## NimbleCSV.ParseError Exception ### Description Represents an error that occurs during the parsing of CSV data using the NimbleCSV library. ### Type Exception ### Module NimbleCSV ### Version 1.3.0 ``` -------------------------------- ### Parse CSV String with RFC4180 Source: https://hexdocs.pm/nimble_csv/NimbleCSV.html Parse a CSV string using the standard RFC4180 implementation, which uses comma as a separator and double-quote as an escape character. Alias it to CSV for convenience. ```nimble_csv iex> alias NimbleCSV.RFC4180, as: CSV iex> CSV.parse_string("name,age\njohn,27") [["john","27"]] ``` -------------------------------- ### Parsing Functions Source: https://hexdocs.pm/nimble_csv/index.html Functions for parsing CSV data from streams or strings. ```APIDOC ## parse_stream(enum, opts) ### Description Lazily parses CSV from a stream and returns a stream of rows. It expects the given enumerable to be line-oriented. ### Parameters #### Arguments - **enum** (Enumerable.t()) - Required - The line-oriented enumerable to parse. - **opts** (keyword()) - Optional - Configuration options. #### Options - **:skip_headers** (boolean) - Optional - When true, skips headers. Defaults to true. ## parse_string(binary, opts) ### Description Eagerly parses CSV from a string and returns a list of rows. ### Parameters #### Arguments - **binary** (binary()) - Required - The CSV string to parse. - **opts** (keyword()) - Optional - Configuration options. #### Options - **:skip_headers** (boolean) - Optional - When true, skips headers. Defaults to true. ``` -------------------------------- ### NimbleCSV.RFC4180 Functions Source: https://hexdocs.pm/nimble_csv/NimbleCSV.RFC4180.html A collection of functions for CSV processing including parsing and dumping operations. ```APIDOC ## dump_to_iodata(enumerable) ### Description Converts an enumerable of rows into CSV-formatted iodata. ### Parameters - **enumerable** (Enumerable) - Required - The collection of rows to be dumped. ## dump_to_stream(enumerable) ### Description Converts an enumerable of rows into a stream of CSV-formatted strings. ### Parameters - **enumerable** (Enumerable) - Required - The collection of rows to be streamed. ## parse_enumerable(enumerable, opts \\\ []) ### Description Parses an enumerable of CSV lines into a list of rows. ### Parameters - **enumerable** (Enumerable) - Required - The collection of CSV lines. - **opts** (KeywordList) - Optional - Parsing options. ## parse_stream(stream, opts \\\ []) ### Description Parses a stream of CSV lines into a stream of rows. ### Parameters - **stream** (Stream) - Required - The stream of CSV lines. - **opts** (KeywordList) - Optional - Parsing options. ## parse_string(string, opts \\\ []) ### Description Parses a CSV-formatted string into a list of rows. ### Parameters - **string** (String) - Required - The CSV content. - **opts** (KeywordList) - Optional - Parsing options. ## to_line_stream(stream) ### Description Converts a stream of CSV data into a stream of individual lines. ### Parameters - **stream** (Stream) - Required - The CSV stream. ``` -------------------------------- ### NimbleCSV Custom Parser Definition Source: https://hexdocs.pm/nimble_csv/index.html Define a custom CSV parser with specific separators and escape characters. ```APIDOC ## Define Custom CSV Parser ### Description Defines a new parser/dumper module with custom options. ### Method `NimbleCSV.define/2` ### Endpoint N/A (Module function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```elixir NimbleCSV.define(MyParser, separator: "\t", escape: "\"") ``` ### Response Defines a new module (e.g., `MyParser`) with parsing and dumping functions. ``` -------------------------------- ### Parse CSV File Stream Lazily Source: https://hexdocs.pm/nimble_csv/NimbleCSV.html Parse a CSV file line by line using streams for lazy processing. It includes copying binary data to prevent issues when sending data to other processes. ```nimble_csv "path/to/csv/file" |> File.stream!(read_ahead: 100_000) |> MyParser.parse_stream() |> Stream.map(fn [name, age] -> %{name: :binary.copy(name), age: String.to_integer(age)} end) |> Stream.run() ``` -------------------------------- ### Process Parsed CSV Data Source: https://hexdocs.pm/nimble_csv/NimbleCSV.html Process the parsed CSV data by mapping each row to a map, converting age to an integer. This demonstrates handling headers and data transformation. ```nimble_csv "name\tage\njohn\t27" |> MyParser.parse_string() |> Enum.map(fn [name, age] -> %{name: name, age: String.to_integer(age)} end) ``` -------------------------------- ### Parse CSV from a Stream Source: https://hexdocs.pm/nimble_csv/NimbleCSV.html Lazily parses CSV data from an enumerable stream, returning a stream of rows. Ensure the input is line-oriented; use `to_line_stream/1` if necessary. Handles `NimbleCSV.ParseError` for invalid CSV. ```elixir @callback parse_stream(enum :: Enumerable.t(), opts :: keyword()) :: Enumerable.t() ``` -------------------------------- ### Callback: parse_stream/1 Source: https://hexdocs.pm/nimble_csv/index.html Lazily parses CSV from an enumerable stream. ```elixir @callback parse_stream(enum :: Enumerable.t()) :: Enumerable.t() ``` -------------------------------- ### parse_stream/2 Source: https://hexdocs.pm/nimble_csv/NimbleCSV.html Lazily parses CSV data from a stream, returning a stream of rows. ```APIDOC ## parse_stream(enum, opts) ### Description Lazily parses CSV from a stream and returns a stream of rows, which is memory efficient for large files. ### Parameters - **enum** (Enumerable.t) - Required - The input stream. - **opts** (keyword) - Optional - Parsing options. ### Response - **stream** (Enumerable.t) - A stream that emits each row as a list of binaries. ``` -------------------------------- ### parse_stream/2 Source: https://hexdocs.pm/nimble_csv/NimbleCSV.html Lazily parses CSV data from an enumerable stream, returning a stream of rows. Handles line-oriented input and raises NimbleCSV.ParseError for invalid CSV. ```APIDOC ## POST /parse_stream ### Description Lazily parses CSV from a stream and returns a stream of rows. It expects the given enumerable to be line-oriented, where each entry in the enumerable is a line. If your stream does not conform to that, you can call `to_line_stream/1` before parsing the stream. Raises `NimbleCSV.ParseError` for an invalid CSV. ### Method POST ### Endpoint /parse_stream ### Parameters #### Query Parameters - **enum** (Enumerable.t()) - Required - The enumerable stream to parse. - **opts** (keyword()) - Optional - Options for parsing. - **:skip_headers** (boolean()) - When `true`, skips headers. Defaults to `true`. Set it to `false` to keep headers or when the CSV has no headers. ### Request Example ```json { "enum": ["line1\nline2"], "opts": { "skip_headers": false } } ``` ### Response #### Success Response (200) - **rows** (Enumerable.t()) - A stream of parsed CSV rows. #### Response Example ```json { "rows": [["value1", "value2"], ["value3", "value4"]] } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.