Selecto.Output.Transformers.CSV (Selecto v0.4.3)
CSV transformer for Selecto query results.
Converts query results to CSV format with configurable options:
- Headers: Include/exclude column headers
- Delimiter: Custom field separators (comma, tab, semicolon, etc.)
- Quoting: Proper escaping for special characters
- Null handling: Custom null value representation
- Streaming: Efficient processing for large datasets
options
Options
:headers- Include headers (default: true):delimiter- Field separator (default: ","):quote_char- Quote character (default: """):null_value- Null representation (default: ""):force_quotes- Quote all fields (default: false):line_ending- Line ending style (default: "\n")
examples
Examples
iex> Selecto.Output.Transformers.CSV.transform(
...> [["Alice", 25], ["Bob", 30]],
...> ["name", "age"],
...> ["name", "age"]
...> )
{:ok, "name,age\nAlice,25\nBob,30\n"}
iex> Selecto.Output.Transformers.CSV.transform(
...> [["John, Jr.", nil]],
...> ["full_name", "age"],
...> ["full_name", "age"],
...> delimiter: ";", null_value: "N/A"
...> )
{:ok, "full_name;age\n\"John, Jr.\";N/A\n"}
Link to this section Summary
Functions
Transform query results to CSV format with streaming support.
Transform query results to CSV format.
Link to this section Functions
Link to this function
stream_transform(rows, columns, aliases, opts \\ [])
Transform query results to CSV format with streaming support.
Returns a stream that yields CSV lines (including header if configured). Efficient for large datasets as it processes rows one at a time.
Link to this function
transform(rows, columns, aliases, opts \\ [])
Transform query results to CSV format.
Returns the complete CSV as a string with optional headers and properly escaped values.