pola-rs/polars-cli

Config for `polars` command

LaurynasMiksys opened this issue · 1 comments

Description

It would be useful to be able to supply non-default polars.Config (available in Python API) to the polars CLI command.
For example, setting numbers of rows in table representation,

> polars -c "SELECT * FROM read_csv('foods.csv') LIMIT 12;"
┌────────────┬──────────┬────────┬──────────┐
│ category   ┆ calories ┆ fats_g ┆ sugars_g │
│ ---        ┆ ---      ┆ ---    ┆ ---      │
│ str        ┆ i64      ┆ f64    ┆ i64      │
╞════════════╪══════════╪════════╪══════════╡
│ vegetables ┆ 45       ┆ 0.5    ┆ 2        │
│ seafood    ┆ 150      ┆ 5.0    ┆ 0        │
│ meat       ┆ 100      ┆ 5.0    ┆ 0        │
│ fruit      ┆ 60       ┆ 0.0    ┆ 11       │
│ seafood    ┆ 140      ┆ 5.0    ┆ 1        │
│ …          ┆ …        ┆ …      ┆ …        │
│ fruit      ┆ 30       ┆ 0.0    ┆ 5        │
│ seafood    ┆ 130      ┆ 5.0    ┆ 0        │
│ fruit      ┆ 50       ┆ 4.5    ┆ 0        │
│ meat       ┆ 110      ┆ 7.0    ┆ 0        │
│ vegetables ┆ 25       ┆ 0.0    ┆ 2        │
└────────────┴──────────┴────────┴──────────┘

would enable

> python -c "import polars as pl; pl.Config.set_tbl_rows(15); print(pl.read_csv('foods.csv', n_rows=12))"
shape: (12, 4)
┌────────────┬──────────┬────────┬──────────┐
│ category   ┆ calories ┆ fats_g ┆ sugars_g │
│ ---        ┆ ---      ┆ ---    ┆ ---      │
│ str        ┆ i64      ┆ f64    ┆ i64      │
╞════════════╪══════════╪════════╪══════════╡
│ vegetables ┆ 45       ┆ 0.5    ┆ 2        │
│ seafood    ┆ 150      ┆ 5.0    ┆ 0        │
│ meat       ┆ 100      ┆ 5.0    ┆ 0        │
│ fruit      ┆ 60       ┆ 0.0    ┆ 11       │
│ seafood    ┆ 140      ┆ 5.0    ┆ 1        │
│ meat       ┆ 120      ┆ 10.0   ┆ 1        │
│ vegetables ┆ 20       ┆ 0.0    ┆ 2        │
│ fruit      ┆ 30       ┆ 0.0    ┆ 5        │
│ seafood    ┆ 130      ┆ 5.0    ┆ 0        │
│ fruit      ┆ 50       ┆ 4.5    ┆ 0        │
│ meat       ┆ 110      ┆ 7.0    ┆ 0        │
│ vegetables ┆ 25       ┆ 0.0    ┆ 2        │
└────────────┴──────────┴────────┴──────────┘

Actually, found some environment variables that already has desired effect, eg. POLARS_FMT_MAX_ROWS