# ModelTablesApp

Source: https://obsvra.com/docs/modeltablesapp

> Pro: move large inline Empirical value lists out of a model into CSV tables, and fold them back in.

> © 2026 Obsvra. This document describes SpiceGrinder and is provided to help you evaluate and use it. It is not a license to reproduce, adapt, or use this material to build a competing product or service. Full terms: the SpiceGrinder EULA.

## NAME

ModelTablesApp — move large inline `Empirical` value lists into CSV tables, and back (Pro)

## SYNOPSIS

```
java -cp spicegrinder-pro.jar com.obsvra.spicegrinder.pro.tools.ModelTablesApp --extract [--min-values N] model [model ...]
java -cp spicegrinder-pro.jar com.obsvra.spicegrinder.pro.tools.ModelTablesApp --inline model [model ...]
```

On a Pro jpackage install:

```
tabulate --extract [--min-values N] model [model ...]
tabulate --inline model [model ...]
```

## DESCRIPTION

An `Empirical` holds its values inline, in the model file: `values="1.25:426, 1.65:345, 0.85:281, ..."`. That is how SpiceGrinder Free holds a reference table, since Free has no external data sources. Popular-value grids fitted from real data can run to hundreds of values, which makes a model hard to read, diff and edit. In Pro, `tabulate --extract` moves such a list into a CSV file beside the model and replaces the `Empirical` with a `FlatFile` that reads it; `tabulate --inline` does the reverse.

The conversion changes nothing about what the model generates. The table holds exactly the `Empirical`'s values and weights, as written, and the model produces the same rows for the same seed. The converted column can still be a `Copula` input: a `FlatFile` (or `Database`) table of one numeric column, read at random, weighted or not, is a distribution just as an `Empirical` is.

`--extract` converts every `Empirical` with at least `--min-values` values (default 20). Each becomes a CSV named `<model>-<node>.csv` beside the model, with a `value,weight` header, and the node becomes:

```xml
<FlatFile name="PriceGrid" file="model-PriceGrid.csv" skipHeader="true" mode="weighted" weightColumn="weight"/>
```

A `FlatFile`'s relative `file` is looked for beside the model first, so the model runs from any folder. An existing file with the same name is reused when its contents are identical (as after `--inline`) and otherwise left alone: nothing is changed, and the tool says why. Every conversion in a file is checked before anything is written.

`--inline` converts back every `FlatFile` in weighted mode with a header that reads a two-column table of plain numbers and weights. The CSV is left in place. `--extract` then `--inline` restores an XML model byte for byte.

In an XML model, only the converted element's text changes, so comments and layout stay as they were. A JSON model is rewritten in the standard layout (see [ModelFormatApp.md](https://obsvra.com/docs/modelformatapp)). Compact (`.sgm`) models aren't supported.

## OPTIONS

- `--extract`: convert every `Empirical` with at least N values into a table.
- `--min-values N`: the threshold for `--extract` (default 20).
- `--inline`: convert every `FlatFile` that reads a `value,weight` table back into an `Empirical`.
- `--version`: print the version.
- `-h`, `--help`: show usage.

## EXIT STATUS

- **0**: done, or nothing to convert.
- **2**: bad arguments, a model or table that can't be read or written, a table name already taken by a different file, or a Free license.

## EXAMPLES

Move every value list of 20 or more into tables:

```
tabulate --extract model.xml
```

Only the really long ones:

```
tabulate --extract --min-values 100 model.xml
```

Bring them back inline, for example to share the model as a single file:

```
tabulate --inline model.xml
```

## SEE ALSO

[Component-Library-Reference.md](https://obsvra.com/docs/component-library-reference) (`Empirical`, `FlatFile`, `Copula`), [ModelFormatApp.md](https://obsvra.com/docs/modelformatapp), [ModelValidatorApp.md](https://obsvra.com/docs/modelvalidatorapp)
