Data::Grid::Table - A table implementation for Data::Grid
Version 0.02_01
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;
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.
This offset tells us to skip N rows after any header. Defaults to zero.
This ARRAY reference of columns will be used in lieu of, or instead of, any header row. Columns (or the header row)
ARRAY
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.
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:
undef
<
while (my $row = <$table>) { ...
Returns the first row in the table, and is equivalent to calling "rewind" and then "next".
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.
Fast forward by $ROWS and return what is there.
$ROWS
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.
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.
Returns the table as CSV.
Dorian Taylor, <dorian at cpan.org>
<dorian at cpan.org>
Data::Grid
Data::Grid::Container
Data::Grid::Row
Data::Grid::Cell
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.
To install Data::Grid, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Grid
CPAN shell
perl -MCPAN -e shell install Data::Grid
For more information on module installation, please visit the detailed CPAN module installation guide.