NAME

Flat::Profile - Streaming-first profiling for CSV/TSV flat files

SYNOPSIS

use Flat::Profile;

my $p = Flat::Profile->new();

my $it = $p->iter_rows(
    path       => "data.csv",
    has_header => 1,
    delimiter  => ",",
    encoding   => "UTF-8",
);

while (my $row = $it->next_row) {
    # $row is an arrayref
}

my $report = $p->profile_file(
    path        => "data.csv",
    has_header  => 1,
    delimiter   => ",",
    null_empty  => 1,
    null_tokens => ["NULL", "NA"],
    example_cap => 10,
    max_errors  => 1000,
);

DESCRIPTION

Flat::Profile is part of the Flat::* series. It provides streaming-first profiling for CSV/TSV inputs for practical ETL and legacy data workflows.

Design goals:

METHODS

new

my $p = Flat::Profile->new();

Constructor. Takes named arguments (currently reserved for future configuration).

iter_rows

my $it = $p->iter_rows(%args);

Returns an iterator object (Flat::Profile::Iterator).

Required named arguments:

Common named arguments:

profile_file

my $report = $p->profile_file(%args);

Profiles a CSV/TSV file in a streaming pass and returns a hashref report.

Key named arguments include:

NULL SEMANTICS

By default, empty string is treated as null:

null_empty => 1   # default

To treat empty string as a value:

null_empty => 0

You can also treat specific exact tokens as null:

null_tokens => ["NULL", "N/A"]

Notes:

RAGGED ROWS

Flat::Profile tracks width mismatches relative to an expected width:

Row numbers in ragged examples use data-row numbering (header excluded): the first data row is row_number 1.

REPORT FORMAT

profile_file() returns a hashref with stable top-level metadata including:

AUTHOR

Sergio de Sousa

Issues: https://github.com/sergio-desousa/Flat-Profile/issues

LICENSE

Perl 5 (Artistic/GPL dual).