### Write Stream to File Source: https://hexdocs.pm/csvlixir/CSVLixir.html Demonstrates writing a stream of data, transformed into CSV strings by CSVLixir.write, directly to a file. Ensure to open the file in write mode. ```Elixir iex> f = File.open!("/tmp/csvlixir.csv", [:write]) iex> 1..3 ...> |> Stream.map(&([&1, &1+1 ,&1+2])) ...> |> CSVLixir.write ...> |> Stream.each(&(IO.write(f, &1))) ...> |> Stream.run iex> File.close(f) iex> File.read!("/tmp/csvlixir.csv") "1,2,3\n2,3,4\n3,4,5\n" iex> File.rm("/tmp/csvlixir.csv") :ok ``` -------------------------------- ### rows(pid, after_fun) Source: https://hexdocs.pm/csvlixir/CSVLixir.IOReader.html Reads characters from a device associated with the provided process ID (pid) and returns a stream of lists of strings. The after_fun is called after the stream is processed. ```APIDOC ## rows(pid, after_fun) ### Description Reads characters from a device and returns a Stream of lists of strings. The `after_fun` is called after the stream is processed. ### Parameters #### Path Parameters - **pid** (pid()) - Required - The process identifier for the device to read from. - **after_fun** (fun()) - Required - The function to be called after the stream processing is complete. ### Response #### Success Response - Returns a stream of lists of strings, where each inner list represents a row of data from the CSV. ### See Also - http://www.trapexit.org/Comma_Separated_Values ``` -------------------------------- ### read(path) Source: https://hexdocs.pm/csvlixir/CSVLixir.html Reads a CSV file from the given path and returns a stream that generates lists of strings. ```APIDOC ## read(path) ### Description Given a path to a file, returns a stream that generates lists of strings. This is useful for processing large CSV files efficiently. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **path** (string) - The file path to the CSV file. ### Response * **stream** (Stream) - A stream that yields lists of strings, where each list represents a row from the CSV file. ### Request Example ```elixir CSVLixir.read("/tmp/csvlixir.csv") |> Enum.to_list ``` ### Response Example ```elixir [["row", "one"], ["row", "two"]] ``` ``` -------------------------------- ### CSVLixir.IOReader Source: https://hexdocs.pm/csvlixir/index.html Reads characters from a device and returns a Stream of lists of strings. ```APIDOC ## CSVLixir.IOReader ### Description Reads characters from a device and returns a Stream of lists of strings. ### Method (Not specified, likely a function call within the library) ### Endpoint (Not applicable, library function) ### Parameters (Not specified) ### Request Example (Not specified) ### Response #### Success Response - Stream of lists of strings ### Response Example (Not specified) ``` -------------------------------- ### write(enum) Source: https://hexdocs.pm/csvlixir/CSVLixir.Writer.html Takes an enum (likely an enumerable collection of rows) and returns a string containing newline-separated CSV rows. ```APIDOC ## write(enum) ### Description Converts an enumerable collection of rows into a single CSV string with newline-separated rows. ### Parameters #### Path Parameters - **enum** (enum) - Required - The enumerable collection of rows to write. ``` -------------------------------- ### write_row(list) Source: https://hexdocs.pm/csvlixir/CSVLixir.Writer.html Takes a list representing a single row and returns a string containing that row formatted for CSV. ```APIDOC ## write_row(list) ### Description Converts a list representing a single row into a CSV formatted string. ### Parameters #### Path Parameters - **list** (list) - Required - The list representing a single row to write. ``` -------------------------------- ### rows(path) Source: https://hexdocs.pm/csvlixir/CSVLixir.FileReader.html Reads UTF-8 characters from a file specified by the path and returns a stream of lists of strings, representing the rows of the CSV file. ```APIDOC ## rows(path) ### Description Reads UTF-8 characters from a file and returns a Stream of lists of strings. ### Function Signature rows(path) ### Parameters #### Path Parameters - **path** (string) - Required - The file path to the CSV file to be read. ``` -------------------------------- ### CSVLixir.IOReader Source: https://hexdocs.pm/csvlixir/api-reference.html Reads characters from a device and returns a Stream of lists of strings. This module provides flexibility for reading from various input sources. ```APIDOC ## CSVLixir.IOReader ### Description Reads characters from a device and returns a Stream of lists of strings. ### Method (Not specified, likely a function call within the CSVLixir module) ### Endpoint (Not applicable, this is an SDK/library interface) ### Parameters (Not specified) ### Request Example (Not specified) ### Response #### Success Response - Stream of lists of strings #### Response Example (Not specified) ``` -------------------------------- ### Read CSV File to Stream Source: https://hexdocs.pm/csvlixir/CSVLixir.html Reads a CSV file from a given path and returns a stream that generates lists of strings. This is useful for processing large CSV files efficiently. ```Elixir iex> f = File.open!("/tmp/csvlixir.csv", [:write]) iex> IO.puts(f, "row,one") iex> IO.puts(f, "row,two") iex> File.close(f) iex> CSVLixir.read("/tmp/csvlixir.csv") ...> |> Enum.to_list [["row", "one"], ["row", "two"]] iex> File.rm("/tmp/csvlixir.csv") :ok ``` -------------------------------- ### read(str) Source: https://hexdocs.pm/csvlixir/CSVLixir.StringReader.html Reads a given string and parses it into a list of lists of strings, representing rows and columns of CSV data. ```APIDOC ## read(str) ### Description Reads a string and returns a list of lists of strings. ### Parameters #### Path Parameters - **str** (string) - Required - The input string containing CSV data. ### Response #### Success Response (200) - **list[list[string]]** - A list of lists, where each inner list represents a row and its elements are the string values of the columns. ``` -------------------------------- ### CSVLixir.StringReader Source: https://hexdocs.pm/csvlixir/index.html Reads a string and returns a list of lists of strings. ```APIDOC ## CSVLixir.StringReader ### Description Reads a string and returns a list of lists of strings. ### Method (Not specified, likely a function call within the library) ### Endpoint (Not applicable, library function) ### Parameters (Not specified) ### Request Example (Not specified) ### Response #### Success Response - List of lists of strings ### Response Example (Not specified) ``` -------------------------------- ### Write List of Lists to CSV Strings Source: https://hexdocs.pm/csvlixir/CSVLixir.html Transforms a list of lists into a stream of CSV formatted strings, with each string ending in a newline. Suitable for generating CSV output from data structures. ```Elixir iex> CSVLixir.write([["first", "row"], [123, 456]]) ...> |> Enum.to_list ["first,row\n", "123,456\n"] ``` -------------------------------- ### CSVLixir.FileReader Source: https://hexdocs.pm/csvlixir/index.html Reads UTF-8 characters from a file and returns a Stream of lists of strings. ```APIDOC ## CSVLixir.FileReader ### Description Reads UTF-8 characters from a file and returns a Stream of lists of strings. ### Method (Not specified, likely a function call within the library) ### Endpoint (Not applicable, library function) ### Parameters (Not specified) ### Request Example (Not specified) ### Response #### Success Response - Stream of lists of strings ### Response Example (Not specified) ``` -------------------------------- ### CSVLixir.FileReader Source: https://hexdocs.pm/csvlixir/api-reference.html Reads UTF-8 characters from a file and returns a Stream of lists of strings. This module is designed for efficient file processing. ```APIDOC ## CSVLixir.FileReader ### Description Reads UTF-8 characters from a file and returns a Stream of lists of strings. ### Method (Not specified, likely a function call within the CSVLixir module) ### Endpoint (Not applicable, this is an SDK/library interface) ### Parameters (Not specified) ### Request Example (Not specified) ### Response #### Success Response - Stream of lists of strings #### Response Example (Not specified) ``` -------------------------------- ### CSVLixir.Writer Source: https://hexdocs.pm/csvlixir/api-reference.html The writer takes a list (write_row) or a list of lists (wrote) and returns a string containing a single row or newline-separated rows. It handles the formatting of data into CSV strings. ```APIDOC ## CSVLixir.Writer ### Description Takes a list (write_row) or a list of lists (wrote) and returns a string containing a single row or newline-separated rows. ### Method (Not specified, likely a function call within the CSVLixir module) ### Endpoint (Not applicable, this is an SDK/library interface) ### Parameters - **write_row** (list) - A list representing a single CSV row. - **wrote** (list of lists) - A list of lists representing multiple CSV rows. ### Request Example (Not specified) ### Response #### Success Response - String containing CSV formatted data (single row or multiple rows). #### Response Example (Not specified) ``` -------------------------------- ### CSVLixir.Writer Source: https://hexdocs.pm/csvlixir/index.html Takes a list (write_row) or a list of lists (wrote) and returns a string containing a single row or newline-separated rows. ```APIDOC ## CSVLixir.Writer ### Description The writer takes a list (write_row) or a list of lists (wrote) and returns a string containing a single row or newline-separated rows. ### Method (Not specified, likely a function call within the library) ### Endpoint (Not applicable, library function) ### Parameters (Not specified) ### Request Example (Not specified) ### Response #### Success Response - String containing a single row or newline-separated rows ### Response Example (Not specified) ``` -------------------------------- ### Write Single Row to CSV String Source: https://hexdocs.pm/csvlixir/CSVLixir.html Converts a single list into a CSV formatted string, ending with a newline. Useful for writing individual records to a CSV file or string. ```Elixir iex> CSVLixir.write_row(["a", "b", "c"]) "a,b,c\n" ``` -------------------------------- ### Parse CSV String Source: https://hexdocs.pm/csvlixir/CSVLixir.html Parses a CSV formatted string into a list of lists. Handles basic CSV formatting including quoted fields and escaped quotes. ```Elixir iex> CSVLixir.parse("abc,def,ghi\n123,456,789") [["abc","def","ghi"],["123","456","789"]] iex> CSVLixir.parse(~s{abc,def,"gh"",""i }) [["abc", "def", "gh\"\\"i"]] iex> f = File.open!("/tmp/csvlixir.csv", [:write]) iex> IO.puts(f, "row,one") iex> IO.puts(f, "row,two") iex> File.close(f) iex> CSVLixir.parse(File.read!("/tmp/csvlixir.csv")) |> Enum.to_list [["row", "one"], ["row", "two"]] iex> File.rm("/tmp/csvlixir.csv") :ok ``` -------------------------------- ### CSVLixir.StringReader Source: https://hexdocs.pm/csvlixir/api-reference.html Reads a string and returns a list of lists of strings. This is useful for parsing CSV data directly from string variables. ```APIDOC ## CSVLixir.StringReader ### Description Reads a string and returns a list of lists of strings. ### Method (Not specified, likely a function call within the CSVLixir module) ### Endpoint (Not applicable, this is an SDK/library interface) ### Parameters (Not specified) ### Request Example (Not specified) ### Response #### Success Response - List of lists of strings #### Response Example (Not specified) ``` -------------------------------- ### parse(str) Source: https://hexdocs.pm/csvlixir/CSVLixir.html Parses a CSV string into a list of lists of strings. Handles quoted fields and escaped quotes. ```APIDOC ## parse(str) ### Description Given a string, returns a list of lists of strings. This function can parse CSV data including quoted fields and escaped quotes. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters * **str** (string) - The CSV data as a string. ### Response * **list** (list) - A list of lists, where each inner list represents a row and its elements are strings. ### Request Example ```elixir CSVLixir.parse("abc,def,ghi\n123,456,789") CSVLixir.parse(~s{abc,def,"gh"",""i"}) ``` ### Response Example ```elixir [["abc","def","ghi"],["123","456","789"]] [["abc", "def", "gh\"i"]] ``` ``` -------------------------------- ### Write Rows with UTF-8 Characters to File Source: https://hexdocs.pm/csvlixir/CSVLixir.html Writes rows containing non-ASCII characters to a file using CSVLixir.write_row. It is important to open the file with the :utf8 option for correct encoding. ```Elixir iex> f = File.open!("/tmp/csvlixir.csv", [:write, :utf8]) iex> IO.write(f, CSVLixir.write_row(["garçon", "waiter"])) iex> IO.write(f, CSVLixir.write_row(["résumé", "resume"])) iex> File.close(f) iex> File.read!("/tmp/csvlixir.csv") "garçon,waiter\nrésumé,resume\n" iex> File.rm("/tmp/csvlixir.csv") :ok ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.