The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Data::Grid::Table - A table implementation for Data::Grid

VERSION

Version 0.06

SYNOPSIS

    my $grid = Data::Grid->parse('arbitrary.csv');

    # Just take the first one, since a CSV will only have one table.
    my ($table) = $grid->tables;

    while (my $row = $table->next) {
        # do some stuff
    }

    # or

    while (my $row = <$table>) {
        # ...
    }

    # or

    my @rows = $table->rows;

    # or

    my @rows = @$table;

METHODS

new

start

This non-negative integer offset tells the table to skip the first N rows, before looking for any header. Defaults to zero.

This flag tells us that the first (logical) row is a header. Defaults to false.

skip

This offset tells us to skip N rows after any header. Defaults to zero.

columns

This ARRAY reference of columns will be used in lieu of, or instead of, any header row. Columns (or the header row)

cursor

Returns the row offset as an integer starting with zero, which is the beginning of the table irrespective of offsets like "start", "header", and "skip". Not to be confused with "position" in Data::Grid::Container.

next

Retrieves the next row in the table or undef when it reaches the end. This method "must be overridden" by a driver subclass. The iteration operator <> is also overloaded for table objects, so you can use it like this:

    while (my $row = <$table>) { ...

first

Returns the first row in the table, and is equivalent to calling "rewind" and then "next".

rewind

Sets the table's cursor back to the first row. Returns the previous position, beginning at zero. This method must be overridden by a driver subclass.

ffwd $ROWS

Fast forward by $ROWS and return what is there.

rows [$FLATTEN];

Retrieves an array of rows all at once. This method overloads the array dereferencing operator @{}, so you can use it like this:

    my @rows = @$table;

Note that this implementation is extremely naïve and you will almost invariably want to override it in a subclass.

height

Gets the height, in rows, of the table. Careful, for drivers that only do sequential access, this means iterating over the whole set, so you might as well.

This implementation is naïve; please override it in a subclass.

as_string

Returns the table as CSV.

AUTHOR

Dorian Taylor, <dorian at cpan.org>

SEE ALSO

COPYRIGHT & LICENSE

Copyright 2010-2018 Dorian Taylor.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.