README.md

# tysv

[![Package Version](https://img.shields.io/hexpm/v/tysv)](https://hex.pm/packages/tysv)
[![Hex Docs](https://img.shields.io/badge/hex-docs-ffaff3)](https://hexdocs.pm/tysv/)

```sh
gleam add tysv
```
```gleam
import gleam/float
import gleam/int
import tysv

pub fn main() -> Nil {
  // Standard CSV
  let data =
    "Vanilla, 23, 0.5
    Strawberry, 24, 0.75
    Mango, 34, 1.75"

  let assert Ok([
    #("Vanilla", 23, 0.5),
    #("Strawberry", 24, 0.75),
    #("Mango", 34, 1.75),
  ]) =
    tysv.row({
      use flavor <- tysv.parsed
      use price <- tysv.parsed
      use kg <- tysv.parsed
      #(flavor, price, kg)
    })
    |> tysv.col(Ok)
    |> tysv.col(int.parse)
    |> tysv.col(float.parse)
    |> tysv.build(data)

  // Modified CSV with ';' as column separator and '|' as row separator
  let data = "Vanilla; 23; 0.5 | Mango; 34; 1.75"

  let assert Ok([#("Vanilla", 23, 0.5), #("Mango", 34, 1.75)]) =
    tysv.init({
      use flavor <- tysv.parsed
      use price <- tysv.parsed
      use kg <- tysv.parsed
      #(flavor, price, kg)
    })
    // Column separator only works when set before any `col` function
    |> tysv.col_sep(";")
    |> tysv.row_sep("|")
    |> tysv.col(Ok)
    |> tysv.col(int.parse)
    |> tysv.col(float.parse)
    |> tysv.build(data)
}
```

Further documentation can be found at <https://hexdocs.pm/tysv>.

## Development

```sh
gleam run   # Run the project
gleam test  # Run the tests
```

## Provenance
All code in this project is written naturally. **No** AI generation or assistance is used to implement any functionality.

## LICENSE
tysv is made available under the terms of the EUPL-1.2 License.