mbitsv

MoonBit native delimited-text parser and data quality toolkit

tsv
csv
dsv
validation
table
moon add CJR-zhang/mbitsv@0.1.0
Download zip
Author
Version
0.1.0
License
MIT
Last updated
7 hours ago
Downloads
2
README

#mbitsv

See README.md.

#
CellChange

pub(all) struct CellChange {
key : String
old_row_number : Int
new_row_number : Int
column : String
old_value : String
new_value : String
} derive(Eq)

#
CellChange::summary

fn CellChange::summary(self : CellChange) -> String

#
ColumnChangeStats

pub(all) struct ColumnChangeStats {
name : String
changed_cells : Int
old_only : Bool
new_only : Bool
} derive(Eq)

#
ColumnChangeStats::impact_score

fn ColumnChangeStats::impact_score(self : ColumnChangeStats) -> Int

#
ColumnChangeStats::summary

fn ColumnChangeStats::summary(self : ColumnChangeStats) -> String

#
ColumnProfile

pub(all) struct ColumnProfile {
name : String
index : Int
empty_count : Int
non_empty_count : Int
integer_count : Int
decimal_count : Int
boolean_count : Int
inferred_kind : FieldKind
required : Bool
} derive(Eq)

Per-column profile inferred from parsed table values.

#
ColumnProfile::kind_label

fn ColumnProfile::kind_label(self : ColumnProfile) -> String

Stable string label for an inferred field kind.

#
ColumnRule

pub(all) struct ColumnRule {
name : String
kind : FieldKind
required : Bool
} derive(Eq)

One column-level validation rule.

#
ColumnStats

pub(all) struct ColumnStats {
name : String
index : Int
row_count : Int
empty_count : Int
non_empty_count : Int
unique_count : Int
duplicate_count : Int
min_length : Int
max_length : Int
average_length : Int
} derive(Eq)

#
ColumnStats::summary

fn ColumnStats::summary(self : ColumnStats) -> String

#
DialectGuess

pub(all) struct DialectGuess {
delimiter : Char
delimiter_name : String
confidence : Int
has_header : Bool
reason : String
config : ParseConfig
} derive(Eq)

Detected delimited-text dialect with a ready-to-use parser config.

#
DialectGuess::summary

fn DialectGuess::summary(self : DialectGuess) -> String

Compact description for logs, CLIs, and review output.

#
DiffColumnPair

type DiffColumnPair derive(Eq)

#
DiffGateReport

pub(all) struct DiffGateReport {
passed : Bool
risk : String
reasons : Array[String]
} derive(Eq)

#
DiffGateReport::summary

fn DiffGateReport::summary(self : DiffGateReport) -> String

#
DiffKeyEntry

type DiffKeyEntry derive(Eq)

#
DuplicateKeyReport

pub(all) struct DuplicateKeyReport {
key : String
old_rows : Array[Int]
new_rows : Array[Int]
} derive(Eq)

#
DuplicateKeyReport::summary

fn DuplicateKeyReport::summary(self : DuplicateKeyReport) -> String

#
FieldKind

pub(all) enum FieldKind {
Text
NonEmpty
Integer
Decimal
Boolean
} derive(Eq)

Supported validation kinds for schema rules.

#
FixSuggestion

pub(all) struct FixSuggestion {
row : Int
column : String
code : String
suggestion : String
} derive(Eq)

A human-readable remediation hint for validation errors.

#
ParseConfig

pub(all) struct ParseConfig {
delimiter : Char
quote : Char
has_header : Bool
trim_unquoted : Bool
skip_empty_lines : Bool
strict_columns : Bool
comment : Char?
} derive(Eq)

Parser configuration for delimited text.

#
ParseError

pub(all) struct ParseError {
code : String
message : String
line : Int
column : Int
} derive(Eq)

Structured parse error with a stable code and source position.

#
QualityGateReport

pub(all) struct QualityGateReport {
passed : Bool
quality_score : Int
density_score : Int
duplicate_row_count : Int
missing_columns : Array[String]
reasons : Array[String]
} derive(Eq)

A deterministic import gate built from table quality and structural checks.

#
QualityGateReport::summary

fn QualityGateReport::summary(self : QualityGateReport) -> String

#
QualityGateReport::to_markdown

fn QualityGateReport::to_markdown(self : QualityGateReport) -> String

Render gate evidence as a compact Markdown table for CI or review records.

#
RequiredColumnsReport

pub(all) struct RequiredColumnsReport {
required_count : Int
present_count : Int
missing_count : Int
missing_columns : Array[String]
} derive(Eq)

#
RequiredColumnsReport::summary

fn RequiredColumnsReport::summary(self : RequiredColumnsReport) -> String

#
RowAddition

pub(all) struct RowAddition {
key : String
row_number : Int
values : Array[String]
} derive(Eq)

#
RowAddition::summary

fn RowAddition::summary(self : RowAddition) -> String

#
RowRecord

pub(all) struct RowRecord {
pairs : Array[(String, String)]
} derive(Eq)

A row represented as header-name/value pairs.

#
RowRecord::get

fn RowRecord::get(self : RowRecord, name : String) -> String?

Look up a value from a row record.

#
RowRemoval

pub(all) struct RowRemoval {
key : String
row_number : Int
values : Array[String]
} derive(Eq)

#
RowRemoval::summary

fn RowRemoval::summary(self : RowRemoval) -> String

#
Schema

pub(all) struct Schema {
columns : Array[ColumnRule]
allow_extra_columns : Bool
} derive(Eq)

A validation schema for header-based tables.

#
SchemaChange

pub(all) struct SchemaChange {
code : String
column : String
message : String
breaking : Bool
} derive(Eq)

#
SchemaCompatibilityReport

pub(all) struct SchemaCompatibilityReport {
compatible : Bool
breaking_changes : Int
non_breaking_changes : Int
changes : Array[SchemaChange]
} derive(Eq)

#
SchemaCompatibilityReport::is_compatible

fn SchemaCompatibilityReport::is_compatible(self : SchemaCompatibilityReport) -> Bool

#
SchemaCompatibilityReport::summary

#
SchemaSpecError

pub(all) struct SchemaSpecError {
code : String
message : String
column : Int
} derive(Eq)

Error returned when parsing a compact schema specification.

#
Table

pub(all) struct Table {
header : Array[String]
rows : Array[Array[String]]
} derive(Eq)

A parsed delimited table.

#
Table::append_column

fn Table::append_column(self : Table, name : String, default_value : String) -> Result[Table, TableTransformError]

#
Table::cell

fn Table::cell(self : Table, row : Int, column : Int) -> String?

Return a cell by zero-based row and column indexes.

#
Table::cell_by_name

fn Table::cell_by_name(self : Table, row : Int, name : String) -> String?

Return a cell by row index and header name.

#
Table::column_count

fn Table::column_count(self : Table) -> Int

Number of columns. Header width is preferred when present.

#
Table::column_values

fn Table::column_values(self : Table, name : String) -> Result[Array[String], TableTransformError]

#
Table::concat

fn Table::concat(self : Table, other : Table) -> Result[Table, TableTransformError]

#
Table::constant_column_names

fn Table::constant_column_names(self : Table) -> Array[String]

#
Table::dedupe_rows

fn Table::dedupe_rows(self : Table) -> Table

#
Table::drop_columns

fn Table::drop_columns(self : Table, names : Array[String]) -> Table

#
Table::duplicate_row_numbers

fn Table::duplicate_row_numbers(self : Table) -> Array[Int]

#
Table::empty_column_names

fn Table::empty_column_names(self : Table) -> Array[String]

#
Table::fill_empty_cells

fn Table::fill_empty_cells(self : Table, replacement : String) -> Table

#
Table::fill_missing_in_column

fn Table::fill_missing_in_column(self : Table, name : String, replacement : String) -> Result[Table, TableTransformError]

#
Table::find_column

fn Table::find_column(self : Table, name : String) -> Int?

Find a header column by name.

#
Table::has_columns

fn Table::has_columns(self : Table, names : Array[String]) -> Bool

#
Table::head

fn Table::head(self : Table, n : Int) -> Table

#
Table::inner_join

fn Table::inner_join(self : Table, other : Table, left_key : String, right_key : String) -> Result[Table, TableTransformError]

#
Table::missing_columns

fn Table::missing_columns(self : Table, names : Array[String]) -> Array[String]

#
Table::quality_gate

fn Table::quality_gate(self : Table, min_quality_score : Int, min_density_score : Int, required_columns : Array[String], reject_duplicates : Bool) -> QualityGateReport

Check whether a table is safe to pass into an import or release workflow. Thresholds are clamped to the inclusive range 0..100.

#
Table::remove_blank_rows

fn Table::remove_blank_rows(self : Table) -> Table

#
Table::rename_column

fn Table::rename_column(self : Table, from : String, to : String) -> Result[Table, TableTransformError]

#
Table::rename_columns

fn Table::rename_columns(self : Table, renames : Array[(String, String)]) -> Result[Table, TableTransformError]

#
Table::replace_column_values

fn Table::replace_column_values(self : Table, name : String, values : Array[String]) -> Result[Table, TableTransformError]

#
Table::row_count

fn Table::row_count(self : Table) -> Int

Number of data rows, excluding the header.

#
Table::select_columns

fn Table::select_columns(self : Table, names : Array[String]) -> Result[Table, TableTransformError]

#
Table::slice_rows

fn Table::slice_rows(self : Table, start : Int, end : Int) -> Table

#
Table::summary

fn Table::summary(self : Table) -> String

Human-readable table summary used by examples and CLI smoke tests.

#
Table::tail

fn Table::tail(self : Table, n : Int) -> Table

#
Table::to_records

fn Table::to_records(self : Table) -> Array[RowRecord]

Convert each row to a name/value record. Missing cells become empty strings.

#
Table::trim_cells

fn Table::trim_cells(self : Table) -> Table

#
Table::value_counts

fn Table::value_counts(self : Table, name : String) -> Result[Array[(String, Int)], TableTransformError]

#
TableDiffError

pub(all) struct TableDiffError {
code : String
message : String
} derive(Eq)

#
TableDiffReport

pub(all) struct TableDiffReport {
key_columns : Array[String]
compared_columns : Array[String]
old_only_columns : Array[String]
new_only_columns : Array[String]
added_rows : Array[RowAddition]
removed_rows : Array[RowRemoval]
changed_cells : Array[CellChange]
unchanged_rows : Int
duplicate_keys : Array[DuplicateKeyReport]
missing_key_rows_old : Array[Int]
missing_key_rows_new : Array[Int]
change_score : Int
} derive(Eq)

#
TableDiffReport::affected_row_count

fn TableDiffReport::affected_row_count(self : TableDiffReport) -> Int

#
TableDiffReport::change_count

fn TableDiffReport::change_count(self : TableDiffReport) -> Int

#
TableDiffReport::changed_keys

fn TableDiffReport::changed_keys(self : TableDiffReport) -> Array[String]

#
TableDiffReport::changes_for_column

fn TableDiffReport::changes_for_column(self : TableDiffReport, column : String) -> Array[CellChange]

#
TableDiffReport::changes_for_key

fn TableDiffReport::changes_for_key(self : TableDiffReport, key : String) -> Array[CellChange]

#
TableDiffReport::column_change_stats

fn TableDiffReport::column_change_stats(self : TableDiffReport) -> Array[ColumnChangeStats]

#
TableDiffReport::gate

fn TableDiffReport::gate(self : TableDiffReport, max_changed_cells : Int, allow_removed_rows : Bool, allow_column_drift : Bool) -> DiffGateReport

#
TableDiffReport::has_changes

fn TableDiffReport::has_changes(self : TableDiffReport) -> Bool

#
TableDiffReport::has_key_change

fn TableDiffReport::has_key_change(self : TableDiffReport, key : String) -> Bool

#
TableDiffReport::keys_with_changes

fn TableDiffReport::keys_with_changes(self : TableDiffReport) -> Array[String]

#
TableDiffReport::migration_steps

fn TableDiffReport::migration_steps(self : TableDiffReport) -> Array[String]

Produce deterministic review steps for a data import or migration run.

#
TableDiffReport::most_changed_columns

fn TableDiffReport::most_changed_columns(self : TableDiffReport, limit : Int) -> Array[ColumnChangeStats]

#
TableDiffReport::risk_level

fn TableDiffReport::risk_level(self : TableDiffReport) -> String

#
TableDiffReport::summary

fn TableDiffReport::summary(self : TableDiffReport) -> String

#
TableDiffReport::to_markdown

fn TableDiffReport::to_markdown(self : TableDiffReport, max_items : Int) -> String

Render a compact Markdown report for review records or pull requests.

#
TableProfile

pub(all) struct TableProfile {
row_count : Int
column_count : Int
empty_cells : Int
quality_score : Int
columns : Array[ColumnProfile]
} derive(Eq)

Whole-table data quality profile.

#
TableProfile::summary

fn TableProfile::summary(self : TableProfile) -> String

Compact profile summary.

#
TableStats

pub(all) struct TableStats {
row_count : Int
column_count : Int
cell_count : Int
empty_cells : Int
non_empty_cells : Int
density_score : Int
duplicate_row_count : Int
columns : Array[ColumnStats]
} derive(Eq)

#
TableStats::summary

fn TableStats::summary(self : TableStats) -> String

#
TableTransformError

pub(all) struct TableTransformError {
code : String
message : String
} derive(Eq)

#
ValidationError

pub(all) struct ValidationError {
row : Int
column : String
code : String
message : String
} derive(Eq)

One validation problem.

#
ValidationReport

pub(all) struct ValidationReport {
errors : Array[ValidationError]
} derive(Eq)

Validation result. Empty errors means the table is valid.

#
ValidationReport::is_valid

fn ValidationReport::is_valid(self : ValidationReport) -> Bool

Whether a validation report has no errors.

#
ValidationReport::summary

fn ValidationReport::summary(self : ValidationReport) -> String

Return a compact summary for logs and examples.

#
ValidationReport::to_markdown

fn ValidationReport::to_markdown(self : ValidationReport) -> String

Render validation errors as a Markdown table.

#
closed_schema

fn closed_schema(columns : Array[ColumnRule]) -> Schema

Build a closed schema: table headers must be covered by the schema.

#
csv_config

fn csv_config() -> ParseConfig

RFC-4180 style CSV defaults.

#
diff_tables_by_key

fn diff_tables_by_key(old_table : Table, new_table : Table, key_columns : Array[String]) -> Result[TableDiffReport, TableDiffError]

Alias for callers that prefer action-first naming.

#
infer_schema

fn infer_schema(table : Table) -> Schema

Infer a closed schema from current table values.

#
open_schema

fn open_schema(columns : Array[ColumnRule]) -> Schema

Build an open schema: extra headers are allowed.

#
optional_column

fn optional_column(name : String, kind : FieldKind) -> ColumnRule

Build an optional column rule.

#
parse_auto

fn parse_auto(input : String) -> Result[Table, ParseError]

Parse text after automatic delimiter/header detection.

#
parse_csv

fn parse_csv(input : String) -> Result[Table, ParseError]

Parse text with CSV defaults.

#
parse_schema_spec

fn parse_schema_spec(spec : String, allow_extra_columns : Bool) -> Result[Schema, SchemaSpecError]

Parse a compact schema specification.

Example: name:non_empty!,age:int?,active:bool.

#
parse_tsv

fn parse_tsv(input : String) -> Result[Table, ParseError]

Parse text with TSV defaults.

#
parse_with

fn parse_with(input : String, config : ParseConfig) -> Result[Table, ParseError]

Parse delimited text with a custom configuration.

#
profile

fn profile(table : Table) -> TableProfile

Build a deterministic quality profile for a parsed table.

#
required_column

fn required_column(name : String, kind : FieldKind) -> ColumnRule

Build a required column rule.

#
required_columns_report

fn required_columns_report(table : Table, schema : Schema) -> RequiredColumnsReport

#
schema_diff

fn schema_diff(previous : Schema, next : Schema) -> SchemaCompatibilityReport

#
schema_to_spec

fn schema_to_spec(schema : Schema) -> String

Serialize a schema back to the compact name:kind! form.

#
sniff

fn sniff(input : String) -> DialectGuess

Detect a likely delimiter and header mode from a text sample.

#
suggest_fixes

fn suggest_fixes(report : ValidationReport) -> Array[FixSuggestion]

Convert validation errors into deterministic repair suggestions.

#
table_diff_by_key

fn table_diff_by_key(old_table : Table, new_table : Table, key_columns : Array[String]) -> Result[TableDiffReport, TableDiffError]

Compare two header-based tables by one or more key columns.

#
table_stats

fn table_stats(table : Table) -> TableStats

#
to_markdown

fn to_markdown(table : Table, max_rows : Int) -> String

Render a small Markdown preview. max_rows limits data rows only.

#
tsv_config

fn tsv_config() -> ParseConfig

TSV defaults. Quoted fields are still supported for embedded tabs/newlines.

#
validate

fn validate(table : Table, schema : Schema) -> ValidationReport

Validate a parsed table against a header-based schema.

#
write_csv

fn write_csv(table : Table) -> String

Write a table as CSV.

#
write_tsv

fn write_tsv(table : Table) -> String

Write a table as TSV.

#
write_with

fn write_with(table : Table, config : ParseConfig) -> String

Write a table using a custom delimiter configuration.

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io