NAME
Sweet::File::DSV
SYNOPSIS
Given a file.dat
in your home dir.
FIELD_A|FIELD_B
foo|bar
2|3
Create a pipe separated value file instance.
my $dir = Sweet::HomeDir->new;
my $file = Sweet::File::DSV->new(
dir => $dir,
name => 'file.dat',
sep => '|',
);
INHERITANCE
Inherits from Sweet::File
.
ATTRIBUTES
header
no_header
separator
Field separator. Must be provided at creation time or in a sub class with _build_sep
method.
METHODS
num_rows
say $file->num_rows; # 2
field
say $file->field(0); # FIELD_A
say $file->field(1); # FIELD_B
fields
my @fields = $file->fields; # ('FIELD_A', 'FIELD_B')
split_row
my $cells = $self->split_row->(0);
say $_ for @$cells;
# foo
# bar
rows
say $_ for $file->rows;
# foo|bar
# 2|3
SEE ALSO
Delimiter-separated values Wikipedia page.