Data-Table-1.78/ 0000755 0054656 0001750 00000000000 13620555675 013733 5 ustar yzhou domain users Data-Table-1.78/aaa.csv 0000644 0054656 0001750 00000000567 13620555675 015202 0 ustar yzhou domain users Amino acid,Entry,Solvent,"Grams ""(a.a.)""/100g sol.","Temp, C",Ref No. Alanine,1,Ethanol,0.0087,25.0,1 L-aspartate,2,Ethanol,0.000196,25.0,2 L-glutamate,3,Ethanol,0.0056,44.93,2 Glycine,4,Ethanol,0.0037,25.0,1 L-allo-isoleucine,5,Ethanol,0.19,79,5 L-isoleucine,6,Ethanol,0.13,79,5 L-leucine,7,Ethanol,0.217,25.0,1 L-proline,8,Ethanol,1.5,19,6 Valiane,9,Ethanol,0.019,25.0,1 Data-Table-1.78/Table.html 0000644 0054656 0001750 00000220773 13620555675 015663 0 ustar yzhou domain users
Data::Table - Data type related to database tables, spreadsheets, CSV/TSV files, HTML table displays, etc.
News: The package now includes "Perl Data::Table Cookbook" (PDF), which may serve as a better learning material.
To download the free Cookbook, visit https://sites.google.com/site/easydatabase/
# some cool ways to use Table.pm
use Data::Table;
$header = ["name", "age"];
$data = [
["John", 20],
["Kate", 18],
["Mike", 23]
];
$t = Data::Table->new($data, $header, 0); # Construct a table object with
# $data, $header, $type=0 (consider
# $data as the rows of the table).
print $t->csv; # Print out the table as a csv file.
$t = Data::Table::fromCSV("aaa.csv"); # Read a csv file into a table object
### Since version 1.51, a new method fromFile can automatically guess the correct file format
# either CSV or TSV file, file with or without a column header line
# e.g.
# $t = Data::Table::fromFile("aaa.csv");
# is equivalent.
print $t->html; # Display a 'portrait' HTML TABLE on web.
use DBI;
$dbh= DBI->connect("DBI:mysql:test", "test", "") or die $DBI::errstr;
my $minAge = 10;
$t = Data::Table::fromSQL($dbh, "select * from mytable where age >= ?", [$minAge]);
# Construct a table form an SQL
# database query.
$t->sort("age", 0, 0); # Sort by col 'age',numerical,ascending
print $t->html2; # Print out a 'landscape' HTML Table.
$row = $t->delRow(2); # Delete the third row (index=2).
$t->addRow($row, 4); # Add the deleted row back as fifth row.
@rows = $t->delRows([0..2]); # Delete three rows (row 0 to 2).
$col = $t->delCol("age"); # Delete column 'age'.
$t->addCol($col, "age",2); # Add column 'age' as the third column
@cols = $t->delCols(["name","phone","ssn"]);
# Delete 3 columns at the same time.
$name = $t->elm(2,"name"); # Element access
$t2=$t->subTable([1, 3..4],['age', 'name']);
# Extract a sub-table
$t->rename("Entry", "New Entry"); # Rename column 'Entry' by 'New Entry'
$t->replace("Entry", [1..$t->nofRow()], "New Entry");
# Replace column 'Entry' by an array of
# numbers and rename it as 'New Entry'
$t->swap("age","ssn"); # Swap the positions of column 'age'
# with column 'ssn' in the table.
$t->colMap('name', sub {return uc}); # Map a function to a column
$t->sort('age',0,0,'name',1,0); # Sort table first by the numerical
# column 'age' and then by the
# string column 'name' in ascending
# order
$t2=$t->match_pattern('$_->[0] =~ /^L/ && $_->[3]<0.2');
# Select the rows that matched the
# pattern specified
$t2=$t->match_pattern_hash('$_{"Amino acid"} =~ /^L-a/ && $_{"Grams \"(a.a.)\""}<0.2'));
# use column name in the pattern, method added in 1.62
$t2=$t->match_string('John'); # Select the rows that matches 'John'
# in any column
$t2=$t->clone(); # Make a copy of the table.
$t->rowMerge($t2); # Merge two tables
$t->colMerge($t2);
$t = Data::Table->new( # create an employ salary table
[
['Tom', 'male', 'IT', 65000],
['John', 'male', 'IT', 75000],
['Tom', 'male', 'IT', 65000],
['John', 'male', 'IT', 75000],
['Peter', 'male', 'HR', 85000],
['Mary', 'female', 'HR', 80000],
['Nancy', 'female', 'IT', 55000],
['Jack', 'male', 'IT', 88000],
['Susan', 'female', 'HR', 92000]
],
['Name', 'Sex', 'Department', 'Salary'], 0);
sub average { # this is an subroutine calculate mathematical average, ignore NULL
my @data = @_;
my ($sum, $n) = (0, 0);
foreach $x (@data) {
next unless $x;
$sum += $x; $n++;
}
return ($n>0)?$sum/$n:undef;
}
$t2 = $t->group(["Department","Sex"],["Name", "Salary"], [sub {scalar @_}, \&average], ["Nof Employee", "Average Salary"]);
# For each (Department,Sex) pair, calculate the number of employees and average salary
$t2 = $t2->pivot("Sex", 0, "Average Salary", ["Department"]);
# Show average salary information in a Department by Sex spreadsheet
This perl package uses perl5 objects to make it easy for manipulating spreadsheet data among disk files, database, and Web publishing.
A table object contains a header and a two-dimensional array of scalars. Four class methods Data::fromFile, Data::Table::fromCSV, Data::Table::fromTSV, and Data::Table::fromSQL allow users to create a table object from a CSV/TSV file or a database SQL selection in a snap.
Table methods provide basic access, add, delete row(s) or column(s) operations, as well as more advanced sub-table extraction, table sorting, record matching via keywords or patterns, table merging, and web publishing. Data::Table class also provides a straightforward interface to other popular Perl modules such as DBI and GD::Graph.
The most updated version of the Perl Data::Table Cookbook is available at https://sites.google.com/site/easydatabase/
We use Data::Table instead of Table, because Table.pm has already been used inside PerlQt module in CPAN.
A table object has three data members:
a reference to an array of array-references. It's basically a reference to a two-dimensional array.
a reference to a string array. The array contains all the column names.
1 means that @$data is an array of table columns (fields) (column-based); 0 means that @$data is an array of table rows (records) (row-based);
Row-based/Column-based are two internal implementations for a table object. E.g., if a spreadsheet consists of two columns lastname and age. In a row-based table, $data = [ ['Smith', 29], ['Dole', 32] ]. In a column-based table, $data = [ ['Smith', 'Dole'], [29, 32] ].
Two implementations have their pros and cons for different operations. Row-based implementation is better for sorting and pattern matching, while column-based one is better for adding/deleting/swapping columns.
Users only need to specify the implementation type of the table upon its creation via Data::Table::new, and can forget about it afterwards. Implementation type of a table should be considered volatile, because methods switch table objects from one type into another internally. Be advised that row/column/element references gained via table::rowRef, table::rowRefs, table::colRef, table::colRefs, or table::elmRef may become stale after other method calls afterwards.
For those who want to inherit from the Data::Table class, internal method table::rotate is used to switch from one implementation type into another. There is an additional internal assistant data structure called colHash in our current implementation. This hash table stores all column names and their corresponding column index number as key-value pairs for fast conversion. This gives users an option to use column name wherever a column ID is expected, so that user don't have to use table::colIndex all the time. E.g., you may say $t->rename('oldColName', 'newColName') instead of $t->rename($t->colIndex('oldColName'), 'newColIdx').
contains a two-dimensional spreadsheet data.
contains all column names.
0 is row-based, 1 is column-based, describe the orientation of @$data.
see table::match_string, table::match_pattern, and table::match_pattern_hash Since 1.62, we recommend you to use $table->{OK} instead, which is a local array reference.
see table::match_string, table::match_pattern, and table::match_pattern_hash Since 1.67, we return the matched row indices in an array. Data::Table::MATCH is this array reference. Here is an example of setting a max price of 20 to all items with UnitPrice > 20.
$t_product->match_pattern_hash('$_{UnitPrice} > 20');
$t_product->setElm($t_product->{MATCH}, 'UnitPrice', 20);
Store default settings, currently it contains CSV_DELIMITER (set to ','), CSV_QUALIFER (set to '"'), and OS (set to 0). see table::fromCSV, table::csv, table::fromTSV, table::tsv for details.
Syntax: return_type method_name ( [ parameter [ = default_value ]] [, parameter [ = default_value ]] )
If method_name starts with table::, this is an instance method, it can be used as $t->method( parameters ), where $t is a table reference.
If method_name starts with Data::Table::, this is a class method, it should be called as Data::Table::method, e.g., $t = Data::Table::fromCSV("filename.csv").
Conventions for local variables:
colID: either a numerical column index or a column name;
rowIdx: numerical row index;
rowIDsRef: reference to an array of column IDs;
rowIdcsRef: reference to an array of row indices;
rowRef, colRef: reference to an array of scalars;
data: ref_to_array_of_ref_to_array of data values;
header: ref to array of column headers;
table: a table object, a blessed reference.
create a new table. It returns a table object upon success, undef otherwise. $data: points to the spreadsheet data. $header: points to an array of column names. Before version 1.69, a column name must have at least one non-digit character. Since version 1.69, this is relaxed. Although integer and numeric column names can now be accepted, when accessing a column by integer, it is first interpreted as a column name. $type: 0 or 1 for row-based/column-based spreadsheet. $enforceCheck: 1/0 to turn on/off initial checking on the size of each row/column to make sure the data argument indeed points to a valid structure. In 1.63, we introduce constants Data::Table::ROW_BASED and Data::Table::COL_BASED as synonyms for $type. To create an empty Data::Table, use new Data::Table([], [], Data::Table::ROW_BASED);
create a new table, which is a subset of the original. It returns a table object. $rowIdcsRef: points to an array of row indices (or a true/false row mask array). $colIDsRef: points to an array of column IDs. The function make a copy of selected elements from the original table. Undefined $rowIdcsRef or $colIDsRef is interpreted as all rows or all columns. The elements in $colIDsRef may be modified as a side effect before version 1.62, fixed in 1.62. If $arg_ref->{useRowMask} is set to 1, $rowIdcsRef is a true/false row mask array, where rows marked as TRUE will be returned. Row mask array is typically the Data::Table::OK set by match_string/match_pattern/match_pattern_hash methods.
make a clone of the original. It return a table object, equivalent to table::subTable(undef,undef).
create a table from a CSV file. return a table object. $name_or_handler: the CSV file name or an already opened file handler. If a handler is used, it's not closed upon return. To read from STDIN, use Data::Table::fromCSV(\*STDIN, 1). $includeHeader: 0 or 1 to ignore/interpret the first line in the file as column names, If it is set to 0, the array in $header is used. If $header is not supplied, the default column names are "col1", "col2", ... optional named argument OS specifies under which operating system the CSV file was generated. 0 for UNIX, 1 for PC and 2 for MAC. If not specified, $Data::Table::DEFAULTS{'OS'} is used, which defaults to UNIX. Basically linebreak is defined as "\n", "\r\n" and "\r" for three systems, respectively.
optional name argument delimiter and qualifier let user replace comma and double-quote by other meaningful single characters. <b>Exception</b>: if the delimiter or the qualifier is a special symbol in regular expression, you must escape it by '\'. For example, in order to use pipe symbol as the delimiter, you must specify the delimiter as '\|'.
optional name argument skip_lines let you specify how many lines in the csv file should be skipped, before the data are interpretted.
optional name argument skip_pattern let you specify a regular expression. Lines that match the regular expression will be skipped.
optional name argument encoding let you specify an encoding method of the csv file. This option is added to fromCSV, fromTSV, fromFile since version 1.69.
The following example reads a DOS format CSV file and writes a MAC format:
$t = Data::Table:fromCSV('A_DOS_CSV_FILE.csv', 1, undef, {OS=>1});
$t->csv(1, {OS=>2, file=>'A_MAC_CSV_FILE.csv'});
open(SRC, 'A_DOS_CSV_FILE.csv') or die "Cannot open A_DOS_CSV_FILE.csv to read!";
$t = Data::Table::fromCSV(\*SRC, 1);
close(SRC);
The following example reads a non-standard CSV file with : as the delimiter, ' as the qaulifier
my $s="col_A:col_B:col_C\n1:2, 3 or 5:3.5\none:'one:two':'double\", single'''";
open my $fh, "<", \$s or die "Cannot open in-memory file\n";
my $t_fh=Data::Table::fromCSV($fh, 1, undef, {delimiter=>':', qualifier=>"'"});
close($fh);
print $t_fh->csv;
# convert to the standard CSV (comma as the delimiter, double quote as the qualifier)
# col_A,col_B,col_C
# 1,"2, 3 or 5",3.5
# one,one:two,"double"", single'"
print $t->csv(1, {delimiter=>':', qualifier=>"'"}); # prints the csv file use the original definition
The following example reads bbb.csv file (included in the package) by skipping the first line (skip_lines=>1), then treats any line that starts with '#' (or space comma) as comments (skip_pattern=>'^\s*#'), use ':' as the delimiter.
$t = Data::Table::fromCSV("bbb.csv", 1, undef, {skip_lines=>1, delimiter=>':', skip_pattern=>'^\s*#'});
Use the optional name argument encoding to specify file encoding method. $t = Data::Table::fromCSV("bbb.csv", 1, undef, {encoding=>'UTF-8'});
Same as Data::Table::fromCSV. However, this is an instant method (that's what 'i' stands for), which can be inherited.
create a table from a TSV file. return a table object. $name: the TSV file name or an already opened file handler. If a handler is used, it's not closed upon return. To read from STDIN, use Data::Table::fromTSV(\*STDIN, 1). $includeHeader: 0 or 1 to ignore/interpret the first line in the file as column names, If it is set to 0, the array in $header is used. If $header is not supplied, the default column names are "col1", "col2", ... optional named argument OS specifies under which operating system the TSV file was generated. 0 for UNIX, 1 for P C and 2 for MAC. If not specified, $Data::Table::DEFAULTS{'OS'} is used, which defaults to UNIX. Basically linebreak is defined as "\n", "\r\n" and "\r" for three systems, respectively. <b>Exception</b>: if the delimiter or the qualifier is a special symbol in regular expression, you must escape it by '\'. For example, in order to use pipe symbol as the delimiter, you must specify the delimiter as '\|'.
optional name argument skip_lines let you specify how many lines in the csv file should be skipped, before the data are interpretted.
optional name argument skip_pattern let you specify a regular expression. Lines that match the regular expression will be skipped.
optional name argument transform_element let you switch on/off \t to tab, \N to undef (etc.) transformation. See TSV FORMAT for details. However, elements are always transformed when export table to tsv format, because not escaping an element containing a tab will be disasterous.
optional name argument encoding enables one to provide an encoding method when open the tsv file.
See similar examples under Data::Table::fromCSV;
Note: read "TSV FORMAT" section for details.
Same as Data::Table::fromTSV. However, this is an instant method (that's what 'i' stands for), which can be inherited.
create a table from a text file. return a table object. $file_name: the file name (cannot take a file handler). linesChecked: the first number of lines used for guessing the input format. The delimiter will have to produce the same number of columns for these lines. By default only check the first 2 lines, 0 means all lines in the file. $arg_ref can take additional parameters, such as OS, has_header, delimiter, transform_element, etc. Encoding allows one to specify encoding methods used to open the file, which defaults to UTF-8.
fromFile is added after version 1.51. It relies on the following new methods to automatically figure out the correct file format in order to call fromCSV or fromTSV internally:
fromFileGuessOS($file_name, {encoding=>'UTF-8'})
returns integer, 0 for UNIX, 1 for PC, 2 for MAC
fromFileGetTopLines($file_name, $os, $lineNumber, {encoding=>'UTF-8'}) # $os defaults to fromFileGuessOS($file_name), if not specified
returns an array of strings, each string represents each row with linebreak removed.
fromFileGuessDelimiter($lineArrayRef) # guess delimiter from ",", "\t", ":";
returns the guessed delimiter string.
fromFileIsHeader($line_concent, $delimiter, $allowNumericHeader) # $delimiter defaults to $Data::Table::DEFAULTS{'CSV_DELIMITER'}
returns 1 or 0.
It first ask fromFileGuessOS to figure out which OS (UNIX, PC or MAC) generated the input file. The fetch the first linesChecked lines using fromFileGetTopLines. It then guesses the best delimiter using fromFileGuessDelimiter, then it checks if the first line looks like a column header row using fromFileIsHeader. Since fromFileGuessOS and fromFileGetTopLines needs to open/close the input file, these methods can only take file name, not file handler. If user specify formatting parameters in $arg_ref, the routine will skip the corresponding guess work. At the end, fromFile simply calls either fromCSV or fromTSV with $arg_ref forwarded. So if you call fromFile({transform_element=>0}) on a TSV file, transform_elment will be passed onto fromTSV calls internally.
fromFileGuessOS finds the linebreak that gives shortest first line (in the priority of UNIX, PC, MAC upon tie). fromFileGuessDelimiter works based on the assumption that the correct delimiter will produce equal number of columns for the given rows. If multiple matches, it chooses the delimiter that gives maximum number of columns. If none matches, it returns the default delimiter. fromFileIsHeader works based on the assumption that no column header can be empty or numeric values. However, if we allow numeric column names (especially integer column names), set {allowNumericHeader => 1}
create a table from the result of an SQL selection query. It returns a table object upon success or undef otherwise. $dbh: a valid database handler. Typically $dbh is obtained from DBI->connect, see "Interface to Database" or DBI.pm. $sql: an SQL query string or a DBI::st object (starting in version 1.61). $vars: optional reference to an array of variable values, required if $sql contains '?'s which need to be replaced by the corresponding variable values upon execution, see DBI.pm for details. Hint: in MySQL, Data::Table::fromSQL($dbh, 'show tables from test') will also create a valid table object.
Data::Table::fromSQL now can take DBI::st instead of a SQL string. This is introduced, so that variable binding (such as CLOB/BLOB) can be done outside the method, for example:
$sql = 'insert into test_table (id, blob_data) values (1, :val)';
$sth = $dbh->prepare($sql);
$sth->bind_param(':val', $blob, {ora_type => SQLT_BIN});
Data::Table::fromSQL($dbh, $sth);
Same as Data::Table::fromSQL. However, this is an instant method (that's what 'i' stands for), whic h can be inherited.
translate a column name into its numerical position, the first column has index 0 as in as any perl array. return -1 for invalid column names.
Since 1.69, we allow integer to be used as a column header. The integer $colID will first be checked against column names, if matched, the corresponding column index is returned. E.g., if column name for the 3rd column is "1", colIndex(1) will return 2 instead of 1! In such case, if one need to access the second column, one has to access it by column name, i.e., $t->col(($t->header)[1]).
return number of columns.
return number of rows.
return the index of the last columns, i.e., nofCol - 1.
return the index of the last rows, i.e., nofRow - 1; This is syntax sugar.
# these two are equivalent
foreach my $i (0 .. $t->lastRow)
foreach my $i (0 .. $t->nofRow - 1)
return whether the table has any column, introduced in 1.63.
returns whether the colID is a table column, introduced in 1.63.
returns the column name for a numeric column index, notice the first column has an index of 0. Introduced in 1.68.
return the value of a table element at [$rowIdx, $colID], undef if $rowIdx or $colID is invalid.
return the reference to a table element at [$rowIdx, $colID], to allow possible modification. It returns undef for invalid $rowIdx or $colID.
Without argument, it returns an array of column names. Otherwise, use the new header.
return the implementation type of the table (row-based/column-based) at the time, be aware that the type of a table should be considered as volatile during method calls.
return a string corresponding to the CSV representation of the table. $header controls whether to print the header line, 1 for yes, 0 for no. optional named argument OS specifies for which operating system the CSV file is generated. 0 for UNIX, 1 for P C and 2 for MAC. If not specified, $Data::Table::DEFAULTS{'OS'} is used. Basically linebreak is defined as "\n", "\r\n" and "\r" for three systems, respectively. if 'file' is given, the csv content will be written into it, besides returning the string. One may specify custom delimiter and qualifier if the other than default are desired.
return a string corresponding to the TSV representation of the table. $header controls whether to print the header line, 1 for yes, 0 for no. optional named argument OS specifies for which operating system the TSV file is generated. 0 for UNIX, 1 for P C and 2 for MAC. If not specified, $Data::Table::DEFAULTS{'OS'} is used. Basically linebreak is defined as "\n", "\r\n" and "\r" for three systems, respectively. if 'file' is given, the tsv content will be written into it, besides returning the string.
Note: read "TSV FORMAT" section for details.
return a string corresponding to a 'Portrait/Landscape'-style html-tagged table. $colorArrayRef_or_colorHashRef: If a hash reference is provided, it will take three CSS class names for odd data rows, even data rows and for the header row. The default hash is {even=>"data_table_even", odd=>"data_table_odd", header=>"data_table_header"). If a hash reference is not found, a reference to an array of three color strings is expected to provided for backgrounds for even-row records, odd-row records, and -der row, respectively. A default color array ("#D4D4BF","#ECECE4","#CCCC99") will be used if $colors isn't defined.
Since version 1.74, users can prevent default coloring by passing in a color array reference ["", "", ""].
Before version 1.59, the parameter can only accept an array reference.
$tag_tbl: a reference to a hash that specifies any legal attributes such as name, border, id, class, etc. for the TABLE tag.
$tag_tr: a reference to a hash that specifies any legal attributes for the TR tag.
$tag_th: a reference to a hash that specifies any legal attributes for the TH tag.
$tag_td: a reference to a hash that specifies any legal attributes for the TD tag.
Notice $tag_tr and $tag_th controls all the rows and columns of the whole table. The keys of the hash are the attribute names in these cases. However, $tag_td is column specific, i.e., you should specify TD attributes for every column separately. The key of %$tag_td are either column names or column indices, the value is a reference to a hash. E.g., $tag_td = {col3 => {'style'=>'background-color:#cccc99;'}}. However, before version 1.74, the value is the full string to be inserted into the TD tag. E.g., $tag_td = {col3 => 'align=right valign=bottom} only change the TD tag in "col3" to be <TD align=right valign=bottom>;. This format is still supported for backward compatibility.
$portrait controls the layout of the table. The default is 1, i.e., the table is shown in the "Portrait" style, like in Excel. 0 means "Landscape". Since version 1.59, tbody and thead tags are added to the portrait mode output.
Since version 1.74, $callback is introduced to give users fine control on the tag for each cell, i.e., for each th/td cells. $callback is a subroutine reference, where the sub is expected to take parameters ($tag, $row_index, $col_index, $col_name, $table), $tag is reference to a hash containing existing TH/TD tags, the sub will return a new tag. The rest of the parameters give sub access to the identity of the table cell, as well as the table itself.
If the following example, the callback function colors each UnitPrice cell based on whether its value is >=20 or <20. It colors each Discontinued cell based on whether its value is TRUE or FALSE. One can also control the column header cells, which has row index of -1. That is the reason we use "$row >=0 " within callback to make sure it cell is not a column header.
$t=Data::Table::fromCSV("Data-Table-1.74/Product.csv",1,undef, {'OS'=>1});
my $callback = sub {
my ($tag, $row, $col, $colName, $table) = @_;
if ($row >=0 && $colName eq 'UnitPrice') {
$tag->{'style'} = 'background-color:'. (($table->elm($row, $col)>=20) ? '#fc8d59':'#91bfdb') . ';';
}
if ($row >=0 && $colName eq 'Discontinued') {
$tag->{'style'} = 'background-color:'. (($table->elm($row, $col) eq 'TRUE') ? '#999999':'#af8dc3') .';';
}
return $tag;
};
print $t->html(undef, undef, undef, undef, undef, undef, $callback);
Attention: You will have to escape HTML-Entities yourself (for example '<' as '<'), if you have characters in you table which need to be escaped. You can do this for example with the escapeHTML-function from CGI.pm (or the HTML::Entities module).
use CGI qw(escapeHTML);
[...]
$t->colMap($columnname, sub{escapeHTML($_)}); # for every column, where HTML-Entities occur.
This method is deprecated. It's here for compatibility. It now simple call html method with $portrait = 0, see previous description.
return a string corresponding to a "Landscape" html-tagged table. This is useful to present a table with many columns, but very few entries. Check the above table::html for parameter descriptions.
This method accepts the same parameters as table::html, returns a wikitable instead.
This method accepts the same parameters as table::html2, returns a wikitable instead in landscape orientation.
modify the value of a table element at [$rowIdx, $colID] to a new value $val. It returns 1 upon success, undef otherwise. In 1.68, setElm can manipulate multiple elements, i.e., $rowIdx and $colIdx can be references to an index array, and setElm() will modifies all cells defined by the grid.
$t->setElm([0..2], ['ColA', 'ColB'], 'new value');
$t->setElm(0, [1..2], 'new value');
# puts a limit on the price of all expensive items
$t_product->match_pattern_hash('$_{UnitPrice} > 20');
$t_product->setElm($t_product->{MATCH}, 'UnitPrice', 20);
add a new row ($rowRef may point to the actual list of scalars, or it can be a hash_ref (supported since version 1.60)). If $rowRef points to a hash, the method will lookup the value of a field by ts column name: $rowRef->{colName}, if not found, undef is used for that field. The new row will be referred as $rowIdx as the result. E.g., addRow($aRow, 0) will put the new row as the very first row. By default, it appends a row to the end. In 1.67, we support {addNewCol => 1}, if specified, a new column will be automatically created for each new element encountered in the $rowRef.
# automatically add a new column "aNewColumn" to $t, in order to hold the new value
$t->addRow({anExistingColumn => 123, aNewColumn => "XYZ"}, undef, {addNewCol => 1});
# $t only had one column, after this call, it will contain a new column 'col2', in order to hold the new value
$t->addRow([123, "XYZ"], undef, {addNewCol => 1});
It returns 1 upon success, undef otherwise.
delete a row at $rowIdx. It will the reference to the deleted row.
delete rows in @$rowIdcsRef. It will return an array of deleted rows in the same order of $rowIdcsRef upon success. upon success.
add a new column ($colRef points to the actual data), the new column will be referred as $colName or $colIdx as the result. E.g., addCol($aCol, 'newCol', 0) will put the new column as the very first column. By default, append a column to the end. It will return 1 upon success or undef otherwise. In 1.68, $colRef can be a scalar, which is the default value that can be used to create the new column. E.g., to create a new column with default value of undef, 0, 'default', respectively, one can do:
$t->addCol(undef, 'NewCol');
$t->addCol(0, 'NewIntCol');
$t->addCol('default', 'NewStringCol');
delete a column at $colID return the reference to the deleted column.
delete a list of columns, pointed by $colIDsRef. It will return an array of deleted columns in the same order of $colIDsRef upon success.
return a reference to the row at $rowIdx upon success or undef otherwise.
return a reference to array of row references upon success, undef otherwise.
return a copy of the row at $rowIdx upon success or undef otherwise.
return a reference to a hash, which contains a copy of the row at $rowIdx, upon success or undef otherwise. The keys in the hash are column names, and the values are corresponding elements in that row. The hash is a copy, therefore modifying the hash values doesn't change the original table.
return a reference to the column at $colID upon success.
return a reference to array of column references upon success.
return a copy to the column at $colID upon success or undef otherwise.
rename the column at $colID to a $newName (the newName must be valid, and should not be identical to any other existing column names). It returns 1 upon success or undef otherwise.
replace the column at $oldColID by the array pointed by $newColRef, and renamed it to $newName. $newName is optional if you don't want to rename the column. It returns 1 upon success or undef otherwise.
swap two columns referred by $colID1 and $colID2. It returns 1 upon success or undef otherwise.
move column referred by $colID to a new location $colIdx. If $newColName is specified, the column will be renamed as well. It returns 1 upon success or undef otherwise.
Rearrange the columns according to the order specified in $colIDRef. Columns not specified in the reference array will be appended to the end! If one would like to drop columns not specified, set $arg_ref to {keepRest => 0}. reorder() changes the table itself, while subTable(undef, $colIDRefs) will return a new table. reorder() might also runs faster than subTable, as elements may not need to be copied.
foreach element in column $colID, map a function $fun to it. It returns 1 upon success or undef otherwise. This is a handy way to format a column. E.g. if a column named URL contains URL strings, colMap("URL", sub {"<a href='$_'>$_</a>"}) before html() will change each URL into a clickable hyper link while displayed in a web browser.
foreach row in the table, map a function $fun to it. It can do whatever colMap can do and more. It returns 1 upon success or undef otherwise. colMap function only give $fun access to the particular element per row, while colsMap give $fun full access to all elements per row. E.g. if two columns named duration and unit (["2", "hrs"], ["30", "sec"]). colsMap(sub {$_->[0] .= " (".$_->[1].")"; } will change each row into (["2 hrs", "hrs"], ["30 sec", "sec"]). As show, in the $func, a column element should be referred as $_->[$colIndex].
sort a table in place. First sort by column $colID1 in $order1 as $type1, then sort by $colID2 in $order2 as $type2, ... $type is 0 for numerical and 1 for others; $order is 0 for ascending and 1 for descending;
In 1.62, instead of memorize these numbers, you can use constants instead (notice constants do not start with '$'). Data::Table::NUMBER Data::Table::STRING Data::Table::ASC Data::Table::DESC
Sorting is done in the priority of colID1, colID2, ... It returns 1 upon success or undef otherwise. Notice the table is rearranged as a result! This is different from perl's list sort, which returns a sorted copy while leave the original list untouched, the authors feel inplace sorting is more natural.
table::sort can take a user supplied operator, this is useful when neither numerical nor alphabetic order is correct.
$Well=["A_1", "A_2", "A_11", "A_12", "B_1", "B_2", "B_11", "B_12"];
$t = Data::Table->new([$Well], ["PlateWell"], 1);
$t->sort("PlateWell", 1, 0);
print join(" ", $t->col("PlateWell"));
# prints: A_1 A_11 A_12 A_2 B_1 B_11 B_12 B_2
# in string sorting, "A_11" and "A_12" appears before "A_2";
my $my_sort_func = sub {
my @a = split /_/, $_[0];
my @b = split /_/, $_[1];
my $res = ($a[0] cmp $b[0]) || (int($a[1]) <=> int($b[1]));
};
$t->sort("PlateWell", $my_sort_func, 0);
print join(" ", $t->col("PlateWell"));
# prints the correct order: A_1 A_2 A_11 A_12 B_1 B_2 B_11 B_12
return a new table consisting those rows evaluated to be true by $pattern upon success or undef otherwise. If $countOnly is set to 1, it simply returns the number of rows that matches the string without making a new copy of table. $countOnly is 0 by default.
Side effect: @Data::Table::OK (should use $t->{OK} after 1.62) stores a true/false array for the original table rows. Using it, users can find out what are the rows being selected/unselected. Side effect: @Data::Table::MATCH stores a reference to an array containing all row indices for matched rows.
In the $pattern string, a column element should be referred as $_->[$colIndex]. E.g., match_pattern('$_->[0]>3 && $_->[1]=~/^L') retrieve all the rows where its first column is greater than 3 and second column starts with letter 'L'. Notice it only takes colIndex, column names are not acceptable here!
return a new table consisting those rows evaluated to be true by $pattern upon success or undef otherwise. If $countOnly is set to 1, it simply returns the number of rows that matches the string without making a new copy of table. $countOnly is 0 by default.
Side effect: @Data::Table::OK stores a reference to a true/false array for the original table rows. Using it, users can find out what are the rows being selected/unselected. Side effect: @Data::Table::MATCH stores a reference to an array containing all row indices for matched rows.
In the $pattern string, a column element should be referred as ${column_name}. match_pattern_hash() is added in 1.62. The difference between this method and match_pattern is each row is fed to the pattern as a hash %_. In the case of match_pattern, each row is fed as an array ref $_. The pattern for match_pattern_hash() becomes much cleaner.
If a table has two columns: Col_A as the 1st column and Col_B as the 2nd column, a filter "Col_A > 2 AND Col_B < 2" is written before as $t->match_pattern('$_->[0] > 2 && $_->[1] <2'); where we need to figure out $t->colIndex('Col_A') is 0 and $t->colIndex('Col_B') is 1, in order to build the pattern. Now you can use column name directly in the pattern: $t->match_pattern_hash('$_{Col_A} >2 && $_{Col_B} <2'); This method creates $t->{OK}, as well as @Data::Table::OK, same as match_pattern().
Simple boolean operators such as and/or can be directly put into the pattern string. More complex logic can also be supported in the example below:
my $t= Data::Table->new([[2,5,'Jan'], [1,6,'Feb'], [-3,2,'Apr'], [6,-4,'Dec']], ['X','Y','Month'], 0);
# we need to use our instead of my, so that %Q1 is accessible within match_pattern_hash
our %Q1 = ('Jan'=>1, 'Feb'=>1, 'Mar'=>1);
# find records belongin to Q1 months, we need to use %::Q1 to access the Q1 defined outside Data::Table
$t2=$t->match_pattern_hash('exists $::Q1{$_{Month}}');
similarly, subroutines can be accessed inside match_pattern_hash using "::":
sub in_Q1 {
my $x = shift;
return ($x eq 'Jan' or $x eq 'Feb' or $x eq 'Mar');
}
$t2=$t->match_pattern_hash('::in_Q1($_{Month})');
However, such usage is discouraged, as match_pattern_hash() does not throw errors when the pattern is invalid. For complex filtering logic, we strongly recommend you stick to row-based looping.
return a new table consisting those rows contains string $s in any of its fields upon success, undef otherwise. if $caseIgnore evaluated to true, case will is be ignored (s/$s/i). If $countOnly is set to 1, it simply returns the number of rows that matches the string without making a new copy of table. $countOnly is 0 by default.
Side effect: @Data::Table::OK stores a reference to a true/false array for the original table rows. Side effect: @Data::Table::MATCH stores a reference to an array containing all row indices for matched rows. Using it, users can find out what are the rows being selected/unselected. The $s string is actually treated as a regular expression and applied to each row element, therefore one can actually specify several keywords by saying, for instance, match_string('One|Other').
mask is reference to an array, where elements are evaluated to be true or false. The size of the mask must be equal to the nofRow of the table. return a new table consisting those rows where the corresponding mask element is true (or false, when complement is set to true).
E.g., $t1=$tbl->match_string('keyword'); $t2=$tbl->rowMask(\@Data::Table::OK, 1) creates two new tables. $t1 contains all rows match 'keyword', while $t2 contains all other rows.
mask is reference to an array, where elements are evaluated to be true or false. The size of the mask must be equal to the nofRow of the table. return a new table consisting those rows where the corresponding mask element is true (or false, when complement is set to true).
E.g., $t1=$tbl->match_string('keyword'); $t2=$tbl->rowMask(\@Data::Table::OK, 1) creates two new tables. $t1 contains all rows match 'keyword', while $t2 contains all other rows.
Returns a reference to a enumerator routine, which enables one to loop through each table row. If $reverse is set to 1, it will enumerate backward. The convenience here is each row is fetch as a rowHashRef, so one can easily access row elements by name.
my $next = $t_product->iterator();
while (my $row = $next->()) {
# have access to a row as a hash reference, access row number by &$next(1);
$t_product->setElm($next->(1), 'ProductName', 'New! '.$row->{ProductName});
}
In this example, each $row is fetched as a hash reference, so one can access the elements by $row->{colName}. Be aware that the elements in the hash is a copy of the original table elements, so modifying $row->{colName} does not modify the original table. If table modification is intended, one needs to obtain the row index of the returned row. $next->(1) call with a non-empty argument returns the row index of the record that was previously fetched with $next->(). In this example, one uses the row index to modify the original table.
Primary key columns are specified in $colsToGroupBy. All rows are grouped by primary keys first (keys sorted as string). Then for each group, subroutines $funToAppy is applied to corresponding rows. $funToApply are passed with two parameters ($tableRef, $rowIDsRef). All rows sharing the key are passed in as a Data::Table object (with all columns and in the order of ascending row index) in the first parameter. The second optional parameter contains an array of row indices of the group members. Since all rows in the passed-in table contains the same keys, the key value can be obtained from its first table row.
Primary key columns are specified in $colsToGroupBy. All rows are grouped by primary keys first. Then for each group, an array of subroutines (in $funsToAppy) are applied to corresponding columns and yield a list of new columns (specified in $newColNames).
$colsToGroupBy, $colsToCalculate are references to array of colIDs. $funsToApply is a reference to array of subroutine references. $newColNames are a reference to array of new column name strings. If specified, the size of arrays pointed by $colsToCalculate, $funsToApply and $newColNames should be i dentical. A column may be used more than once in $colsToCalculate.
$keepRestCols is default to 1 (was introduced as 0 in 1.64, changed to 1 in 1.66 for backward compatibility) introduced in 1.64), otherwise, the remaining columns are returned with the first encountered value of that group.
E.g., an employee salary table $t contains the following columns: Name, Sex, Department, Salary. (see examples in the SYNOPSIS)
$t2 = $t->group(["Department","Sex"],["Name", "Salary"], [sub {scalar @_}, \&average], ["Nof Employee", "Average Salary"], 0);
Department, Sex are used together as the primary key columns, a new column "Nof Employee" is created by counting the number of employee names in each group, a new column "Average Salary" is created by averaging the Salary data falled into each group. As the result, we have the head count and average salary information for each (Department, Sex) pair. With your own functions (such as sum, product, average, standard deviation, etc), group method is very handy for accounting purpose. If primary key columns are not defined, all records will be treated as one group.
$t2 = $t->group(undef,["Name", "Salary"], [sub {scalar @_}, \&average], ["Nof Employee", "Average Salary"], 0);
The above statement will output the total number of employees and their average salary as one line.
Every unique values in a column (specified by $colToSplit) become a new column. undef value become "NULL". $colToSplitIsStringOrNumeric is set to numeric (0 or Data::Table:NUMBER), the new column names are prefixed by "oldColumnName=". The new cell element is filled by the value specified by $colToFill (was 1/0 before version 1.63).
Note: yes, it seems I made an incompatible change in version 1.64, where $colToSplitIsStringOrNumber used to be $colToSplitIsNumeric, where 0 meant STRING and 1 meant NUMBER. Now it is opposite. However, I also added auto-type detection code, that this parameter essentially is auto-guessed and most old code should behave the same as before.
When primary key columns are specified by $colsToGroupBy, all records sharing the same primary key collapse into one row, with values in $colToFill filling the corresponding new columns. If $colToFill is not specified, a cell is filled with the number of records fall into that cell.
$colToSplit and $colToFill are colIDs. $colToSplitIsNumeric is 1/0. $colsToGroupBy is a reference to array of colIDs. $keepRestCols is 1/0, by default is 0. If $keepRestCols is off, only primary key columns and new columns are exported, otherwise, all the rest columns are exported as well.
E.g., applying pivot method to the resultant table of the example of the group method.
$t2->pivot("Sex", 0, "Average Salary",["Department"]);
This creates a 2x3 table, where Departments are use as row keys, Sex (female and male) become two new columns. "Average Salary" values are used to fill the new table elements. Used together with group method, pivot method is very handy for accounting type of analysis. If $colsToGroupBy is left as undef, all rows are treated as one group. If $colToSplit is left as undef, the method will generate a column named "(all)" that matches all records share the corresponding primary key.
The idea of melt() and cast() are taken from Hadley Wickham's Reshape package in R language. A table is first melt() into a tall-skiny format, where measurements are stored in the format of a variable-value pair per row. Such a format can then be easily cast() into various contingency tables.
One needs to specify the columns consisting of primary keys, columns that are consider as variable columns. The output variable column is named 'variable' unless specified by $arg_ref{variableColName}. The output value column is named 'value', unless specified in $arg_ref{valueColName}. By default NULL values are not output, unless $arg_ref{skip_NULL} is set to false. By default empty string values are kept, unless one sets skip_empty to `.
For each object (id), we measure variable x1 and x2 at two time points
$t = new Data::Table([[1,1,5,6], [1,2,3,5], [2,1,6,1], [2,2,2,4]], ['id','time','x1','x2'], Data::Table::ROW_BASED);
# id time x1 x2
# 1 1 5 6
# 1 2 3 5
# 2 1 6 1
# 2 2 2 4
# melting a table into a tall-and-skinny table
$t2 = $t->melt(['id','time']);
#id time variable value
# 1 1 x1 5
# 1 1 x2 6
# 1 2 x1 3
# 1 2 x2 5
# 2 1 x1 6
# 2 1 x2 1
# 2 2 x1 2
# 2 2 x2 4
# casting the table, &average is a method to calculate mean
# for each object (id), we calculate average value of x1 and x2 over time
$t3 = $t2->cast(['id'],'variable',Data::Table::STRING,'value', \&average);
# id x1 x2
# 1 4 5.5
# 2 4 2.5
see melt(), as melt() and cast() are meant to use together.
The table has been melten before. cast() group the table according to primary keys specified in $colsToGroupBy. For each group of objects sharing the same id, it further groups values (specified by $colToCalculate) according to unique variable names (specified by $colToSplit). Then it applies subroutine $funToApply to obtain an aggregate value. For the output, each unique primary key will be a row, each unique variable name will become a column, the cells are the calculated aggregated value.
If $colsToGroupBy is undef, all rows are treated as within the same group. If $colToSplit is undef, a new column "(all)" is used to hold the results.
$t = Data::Table->new( # create an employ salary table
[
['Tom', 'male', 'IT', 65000],
['John', 'male', 'IT', 75000],
['Tom', 'male', 'IT', 65000],
['John', 'male', 'IT', 75000],
['Peter', 'male', 'HR', 85000],
['Mary', 'female', 'HR', 80000],
['Nancy', 'female', 'IT', 55000],
['Jack', 'male', 'IT', 88000],
['Susan', 'female', 'HR', 92000]
],
['Name', 'Sex', 'Department', 'Salary'], Data::Table::ROW_BASED);
# get a Department x Sex contingency table, get average salary across all four groups
print $t->cast(['Department'], 'Sex', Data::Table::STRING, 'Salary', \&average)->csv(1);
Department,female,male
IT,55000,73600
HR,86000,85000
# get average salary for each department
print $t->cast(['Department'], undef, Data::Table::STRING, 'Salary', \&average)->csv(1);
Department,(all)
IT,70500
HR,85666.6666666667
# get average salary for each gender
print $t->cast(['Sex'], undef, Data::Table::STRING, 'Salary', \&average)->csv(1);
Sex,(all)
male,75500
female,75666.6666666667
# get average salary for all records
print $t->cast(undef, undef, Data::Table::STRING, 'Salary', \&average)->csv(1);
(all)
75555.5555555556
Append all the rows in the table object $tbl to the original rows. Before 1.62, the merging table $tbl must have the same number of columns as the original, as well as the columns are in exactly the same order. It returns 1 upon success, undef otherwise. The table object $tbl should not be used afterwards, since it becomes part of the new table.
Since 1.62, you may provide {byName =>1, addNewCol=>1} as $argRef. If byName is set to 1, the columns in in $tbl do not need to be in the same order as they are in the first table, instead the column name is used for the matching. If addNewCol is set to 1, if $tbl contains a new column name that does not already exist in the first table, this new column will be automatically added to the resultant table. Typically, you want to specify there two options simultaneously.
Append all the columns in table object $tbl to the original columns. Table $tbl must have the same number of rows as the original. It returns 1 upon success, undef otherwise. Table $tbl should not be used afterwards, since it becomes part of the new table.
Since 1.62, you can specify {renameCol => 1} as $argRef. This is to auto fix any column name collision. If $tbl contains a column that already exists in the first table, it will be renamed (by a suffix _2) to avoid the collision.
Join two tables. The following join types are supported (defined by $type):
0: inner join 1: left outer join 2: right outer join 3: full outer join
In 1.62, instead of memorize these numbers, you can use constants instead (notice constants do not start with '$'). Data::Table::INNER_JOIN Data::Table::LEFT_JOIN Data::Table::RIGHT_JOIN Data::Table::FULL_JOIN
$cols1 and $cols2 are references to array of colIDs, where rows with the same elements in all listed columns are merged. As the result table, columns listed in $cols2 are deleted, before a new table is returned.
The implementation is hash-join, the running time should be linear with respect to the sum of number of rows in the two tables (assume both tables fit in memory).
If the non-key columns of the two tables share the same name, the routine will fail, as the result table cannot contain two columns of the same name. In 1.62, one can specify {renameCol=>1} as $argRef, so that the second column will be automatically renamed (with suffix _2) to avoid collision.
If you would like to treat the NULLs in the key columns as empty string, set {NULLasEmpty => 1}. If you do not want to treat NULLs as empty strings, but you still like the NULLs in two tables to be considered as equal (but not equal to ''), set {matchNULL => 1}. Obviously if NULLasEmpty is set to 1, matchNULL will have no effect.
All internal methods are mainly implemented for used by other methods in the Table class. Users should avoid using them. Nevertheless, they are listed here for developers who would like to understand the code and may derive a new class from Data::Table.
convert the internal structure of a table between row-based and column-based. return 1 upon success, undef otherwise.
Encode a scalar into a CSV-formatted field.
optional named arguments: delimiter and qualifier, in case user wants to use characters other than the defaults. The default delimiter and qualifier is taken from $Data::Table::DEFAULTS{'CSV_DELIMITER'} (defaults to ',') and $Data::Table::DEFAULTS{'CSV_QUALIFIER'} (defaults to '"'), respectively.
Please note that this function only escape one element in a table. To escape the whole table row, you need to join($delimiter, map {csvEscape($_)} @row . $endl; $endl refers to End-of-Line, which you may or may not want to add, and it is OS-dependent. Therefore, csvEscape method is kept to the simplest form as an element transformer.
Break a CSV encoded string to an array of scalars (check it out, we did it the cool way).
optional argument size: specify the expected number of fields after csv-split. optional named arguments: delimiter and qualifier, in case user wants to use characters other than the defaults. respectively. The default delimiter and qualifier is taken from $Data::Table::DEFAULTS{'CSV_DELIMITER'} (defaults to ',') and $Data::Table::DEFAULTS{'CSV_QUALIFIER'} (defaults to '"'), respectively.
Encode a scalar into a TSV-formatted string.
There is no standard for TSV format as far as we know. CSV format can't handle binary data very well, therefore, we choose the TSV format to overcome this limitation.
We define TSV based on MySQL convention.
"\0", "\n", "\t", "\r", "\b", "'", "\"", and "\\" are all escaped by '\' in the TSV file.
(Warning: MySQL treats '\f' as 'f', and it's not escaped here)
Undefined values are represented as '\N'.
However, you can switch off this transformation by setting {transform_element => 0} in the fromTSV or tsv method. Before if a cell reads 'A line break is \n', it is read in as 'A link break is [return]' in memory. When use tsv method to export, it is transformed back to 'A line break is \n'. However, if it is exported as a csv, the [return] will break the format. Now if transform_element is set to 0, the cell is stored as 'A line break is \n' in memory, so that csv export will be correct. However, do remember to set {transform_element => 0} in tsv export method, otherwise, the cell will become 'A line break is \\n'. Be aware that trasform_element controls column headers as well.
Spreadsheet is a very generic type, therefore Data::Table class provides an easy interface between databases, web pages, CSV/TSV files, graphics packages, etc.
Here is a summary (partially repeat) of some classic usages of Data::Table.
use DBI;
$dbh= DBI->connect("DBI:mysql:test", "test", "") or die $DBI::errstr;
my $minAge = 10;
$t = Data::Table::fromSQL($dbh, "select * from mytable where age >= ?", [$minAge]);
print $t->html;
$t = fromFile("mydata.csv"); # after version 1.51
$t = fromFile("mydata.tsv"); # after version 1.51
$t = fromCSV("mydata.csv");
$t->sort(1,1,0);
print $t->csv;
Same for TSV
Read in two tables from NorthWind.xls file, writes them out to XLSX format. See Data::Table::Excel module for details.
use Data::Table::Excel;
my ($tableObjects, $tableNames)=xls2tables("NorthWind.xls");
$t_category = $tableObjects[0];
$t_product = $tableObjects[1];
tables2xlsx("NorthWind.xlsx", [$t_category, $t_product]);
use GD::Graph::points;
$graph = GD::Graph::points->new(400, 300);
$t2 = $t->match('$_->[1] > 20 && $_->[3] < 35.7');
my $gd = $graph->plot($t->colRefs([0,2]));
open(IMG, '>mygraph.png') or die $!;
binmode IMG;
print IMG $gd->png;
close IMG;
Copyright 1998-2008, Yingyao Zhou & Guangzhou Zou. All rights reserved.
It was first written by Zhou in 1998, significantly improved and maintained by Zou since 1999. The authors thank Tong Peng and Yongchuang Tao for valuable suggestions. We also thank those who kindly reported bugs, some of them are acknowledged in the "Changes" file.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Please send bug reports and comments to: easydatabase at gmail dot com. When sending bug reports, please provide the version of Table.pm, the version of Perl.
DBI, GD::Graph, Data::Table::Excel.
Data-Table-1.78/ttt.tsv 0000644 0054656 0001750 00000000034 13620555675 015301 0 ustar yzhou domain users COL_A COL_B
a\tz b
p\N d\tf
Data-Table-1.78/MYMETA.json 0000644 0054656 0001750 00000002147 13620555675 015626 0 ustar yzhou domain users {
"abstract" : "Data type related to database tables, spreadsheets, CSV/TSV files, HTML table displays, etc.",
"author" : [
"Yingyao Zhou, Guangzhou Zou"
],
"dynamic_config" : 0,
"generated_by" : "ExtUtils::MakeMaker version 7.34, CPAN::Meta::Converter version 2.150010",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : 2
},
"name" : "Data-Table",
"no_index" : {
"directory" : [
"t",
"inc"
]
},
"prereqs" : {
"build" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"runtime" : {
"requires" : {
"Carp" : "0",
"perl" : "5.006"
}
},
"test" : {
"requires" : {
"Test::More" : "0"
}
}
},
"release_status" : "stable",
"resources" : {},
"version" : "1.78",
"x_serialization_backend" : "JSON::PP version 2.97001"
}
Data-Table-1.78/Category.csv 0000644 0054656 0001750 00000000622 13620555675 016225 0 ustar yzhou domain users CategoryID,CategoryName,Description
1,Beverages,"Soft drinks, coffees, teas, beers, and ales"
2,Condiments,"Sweet and savory sauces, relishes, spreads, and seasonings"
3,Confections,"Desserts, candies, and sweet breads"
4,Dairy Products,Cheeses
5,Grains/Cereals,"Breads, crackers, pasta, and cereal"
6,Meat/Poultry,Prepared meats
7,Produce,Dried fruit and bean curd
8,Seafood,Seaweed and fish
Data-Table-1.78/bbb.csv 0000644 0054656 0001750 00000000720 13620555675 015174 0 ustar yzhou domain users ***** This table is the same as the aaa.csv ****
# lines start with # are comment lines
Amino acid:Entry:Solvent:"Grams ""(a.a.)""/100g sol.":"Temp, C":Ref No.
Alanine:1:Ethanol:0.0087:25.0:1
L-aspartate:2:Ethanol:0.000196:25.0:2
L-glutamate:3:Ethanol:0.0056:44.93:2
Glycine:4:Ethanol:0.0037:25.0:1
L-allo-isoleucine:5:Ethanol:0.19:79:5
L-isoleucine:6:Ethanol:0.13:79:5
L-leucine:7:Ethanol:0.217:25.0:1
L-proline:8:Ethanol:1.5:19:6
Valiane:9:Ethanol:0.019:25.0:1
Data-Table-1.78/t_unix.csv 0000644 0054656 0001750 00000000022 13620555675 015750 0 ustar yzhou domain users a,b,c
1,2,3
4,5,6
Data-Table-1.78/t_mac.csv 0000644 0054656 0001750 00000000022 13620555675 015525 0 ustar yzhou domain users a,b,c
1,2,3
4,5,6
Data-Table-1.78/Product.csv 0000644 0054656 0001750 00000005443 13620555675 016076 0 ustar yzhou domain users ProductID,ProductName,CategoryID,UnitPrice,UnitsInStock,Discontinued
1,Chai,1,18,39,FALSE
2,Chang,1,19,17,FALSE
3,Aniseed Syrup,2,10,13,FALSE
4,Chef Anton's Cajun Seasoning,2,22,53,FALSE
5,Chef Anton's Gumbo Mix,2,21.35,0,TRUE
6,Grandma's Boysenberry Spread,2,25,120,FALSE
7,Uncle Bob's Organic Dried Pears,7,30,15,FALSE
8,Northwoods Cranberry Sauce,2,40,6,FALSE
9,Mishi Kobe Niku,6,97,29,TRUE
10,Ikura,8,31,31,FALSE
11,Queso Cabrales,4,21,22,FALSE
12,Queso Manchego La Pastora,4,38,86,FALSE
13,Konbu,8,6,24,FALSE
14,Tofu,7,23.25,35,FALSE
15,Genen Shouyu,2,15.5,39,FALSE
16,Pavlova,3,17.45,29,FALSE
17,Alice Mutton,6,39,0,TRUE
18,Carnarvon Tigers,8,62.5,42,FALSE
19,Teatime Chocolate Biscuits,3,9.2,25,FALSE
20,Sir Rodney's Marmalade,3,81,40,FALSE
21,Sir Rodney's Scones,3,10,3,FALSE
22,Gustaf's Knackebrod,5,21,104,FALSE
23,Tunnbrod,5,9,61,FALSE
24,Guarana Fantastica,1,4.5,20,TRUE
25,NuNuCa Nub-Nougat-Creme,3,14,76,FALSE
26,Gumbar Gummibarchen,3,31.23,15,FALSE
27,Schoggi Schokolade,3,43.9,49,FALSE
28,Rossle Sauerkraut,7,45.6,26,TRUE
29,Thuringer Rostbratwurst,6,123.79,0,TRUE
30,Nord-Ost Matjeshering,8,25.89,10,FALSE
31,Gorgonzola Telino,4,12.5,0,FALSE
32,Mascarpone Fabioli,4,32,9,FALSE
33,Geitost,4,2.5,112,FALSE
34,Sasquatch Ale,1,14,111,FALSE
35,Steeleye Stout,1,18,20,FALSE
36,Inlagd Sill,8,19,112,FALSE
37,Gravad lax,8,26,11,FALSE
38,Cote de Blaye,1,263.5,17,FALSE
39,Chartreuse verte,1,18,69,FALSE
40,Boston Crab Meat,8,18.4,123,FALSE
41,Jack's New England Clam Chowder,8,9.65,85,FALSE
42,Singaporean Hokkien Fried Mee,5,14,26,TRUE
43,Ipoh Coffee,1,46,17,FALSE
44,Gula Malacca,2,19.45,27,FALSE
45,Rogede sild,8,9.5,5,FALSE
46,Spegesild,8,12,95,FALSE
47,Zaanse koeken,3,9.5,36,FALSE
48,Chocolade,3,12.75,15,FALSE
49,Maxilaku,3,20,10,FALSE
50,Valkoinen suklaa,3,16.25,65,FALSE
51,Manjimup Dried Apples,7,53,20,FALSE
52,Filo Mix,5,7,38,FALSE
53,Perth Pasties,6,32.8,0,TRUE
54,Tourtiere,6,7.45,21,FALSE
55,Pate chinois,6,24,115,FALSE
56,Gnocchi di nonna Alice,5,38,21,FALSE
57,Ravioli Angelo,5,19.5,36,FALSE
58,Escargots de Bourgogne,8,13.25,62,FALSE
59,Raclette Courdavault,4,55,79,FALSE
60,Camembert Pierrot,4,34,19,FALSE
61,Sirop d'erable,2,28.5,113,FALSE
62,Tarte au sucre,3,49.3,17,FALSE
63,Vegie-spread,2,43.9,24,FALSE
64,Wimmers gute Semmelknodel,5,33.25,22,FALSE
65,Louisiana Fiery Hot Pepper Sauce,2,21.05,76,FALSE
66,Louisiana Hot Spiced Okra,2,17,4,FALSE
67,Laughing Lumberjack Lager,1,14,52,FALSE
68,Scottish Longbreads,3,12.5,6,FALSE
69,Gudbrandsdalsost,4,36,26,FALSE
70,Outback Lager,1,15,15,FALSE
71,Flotemysost,4,21.5,26,FALSE
72,Mozzarella di Giovanni,4,34.8,14,FALSE
73,Rod Kaviar,8,15,101,FALSE
74,Longlife Tofu,7,10,4,FALSE
75,Rhonbrau Klosterbier,1,7.75,125,FALSE
76,Lakkalikoori,1,18,57,FALSE
77,Original Frankfurter grune Sobe,2,13,32,FALSE
Data-Table-1.78/pod2htmd.tmp 0000644 0054656 0001750 00000000003 13620555675 016167 0 ustar yzhou domain users
.
Data-Table-1.78/ccc.csv 0000644 0054656 0001750 00000000065 13620555675 015201 0 ustar yzhou domain users Department,female,male
IT,55000,76000
HR,86000,85000
Data-Table-1.78/t_dos2.csv 0000644 0054656 0001750 00000000021 13620555675 015633 0 ustar yzhou domain users a b c
1 2
4 6
Data-Table-1.78/Makefile.PL 0000644 0054656 0001750 00000004531 13620555675 015710 0 ustar yzhou domain users use ExtUtils::MakeMaker;
# See lib/ExtUtils/MakeMaker.pm for details of how to influence
# the contents of the Makefile that is written.
# perl 5.005 is required for qr() support
# perl 5.006 is required for 2-arg binmode, autovivifying filehandles
# see README for details
#
require 5.006;
WriteMakefile1(
ABSTRACT_FROM => 'Table.pm',
'NAME' => 'Data::Table',
'VERSION_FROM' => 'Table.pm', # finds $VERSION
'PREREQ_PM' => {
#bytes => 0,
Carp => 0,
},
MIN_PERL_VERSION => '5.006',
META_MERGE => {
resources => {
#repository => 'URL to repository here',
},
},
TEST_REQUIRES => {
'Test::More' => 0,
},
'LICENSE' => 'perl',
'AUTHOR' => 'Yingyao Zhou, Guangzhou Zou',
$^O =~/win/i ? (
dist => {
TAR => 'ptar',
TARFLAGS => '-c -C -f',
},
) : (),
);
sub WriteMakefile1 { #Compatibility code for old versions of EU::MM. Written by Alexandr Ciornii, version 0.23. Added by eumm-upgrade.
my %params=@_;
my $eumm_version=$ExtUtils::MakeMaker::VERSION;
$eumm_version=eval $eumm_version;
die "EXTRA_META is deprecated" if exists $params{EXTRA_META};
die "License not specified" if not exists $params{LICENSE};
if ($params{AUTHOR} and ref($params{AUTHOR}) eq 'ARRAY' and $eumm_version < 6.5705) {
$params{META_ADD}->{author}=$params{AUTHOR};
$params{AUTHOR}=join(', ',@{$params{AUTHOR}});
}
if ($params{TEST_REQUIRES} and $eumm_version < 6.64) {
$params{BUILD_REQUIRES}={ %{$params{BUILD_REQUIRES} || {}} , %{$params{TEST_REQUIRES}} };
delete $params{TEST_REQUIRES};
}
if ($params{BUILD_REQUIRES} and $eumm_version < 6.5503) {
#EUMM 6.5502 has problems with BUILD_REQUIRES
$params{PREREQ_PM}={ %{$params{PREREQ_PM} || {}} , %{$params{BUILD_REQUIRES}} };
delete $params{BUILD_REQUIRES};
}
delete $params{CONFIGURE_REQUIRES} if $eumm_version < 6.52;
delete $params{MIN_PERL_VERSION} if $eumm_version < 6.48;
delete $params{META_MERGE} if $eumm_version < 6.46;
delete $params{META_ADD} if $eumm_version < 6.46;
delete $params{LICENSE} if $eumm_version < 6.31;
WriteMakefile(%params);
}
Data-Table-1.78/MANIFEST 0000644 0054656 0001750 00000000606 13620555675 015066 0 ustar yzhou domain users Changes
Makefile.PL
MANIFEST
README
Table.pm
t/test.t
t/test1.t
aaa.csv
aaa.tsv
bbb.csv
ccc.csv
t_dos.csv
t_dos2.csv
t_unix.csv
t_unix_noheader.csv
t_mac.csv
colon.csv
ttt.tsv
ttt.csv
Category.csv
Product.csv
Table.html
META.yml Module YAML meta-data (added by MakeMaker)
META.json Module JSON meta-data (added by MakeMaker)
Data-Table-1.78/ttt.csv 0000644 0054656 0001750 00000000034 13620555675 015260 0 ustar yzhou domain users COL_A,COL_B
a\tz,b
p\N,d\tf
Data-Table-1.78/README 0000644 0054656 0001750 00000002526 13620555675 014620 0 ustar yzhou domain users Table - Data type related to database tables, spreadsheets, CSV/TSV files, HTML table displays, etc.
Copyright (c) 1998-2006 Yingyao Zhou & Guangzhou Zou
See COPYRIGHT section in Table.pm for usage and distribution rights.
The Table.pm file contains the documentation.
You can obtained the most recent version from
#http://www.geocities.com/easydatabase/
# this URL is obsolete, please use CPAN URL
See also http://www.perl.com/CPAN/
BUILDING
perl Makefile.PL
make
make test
make install (if the tests look okay)
PROBLEMS
1. Perl version is older than 5.005
The package uses operator qr, which was introduced in 5.005
If you have older perl versions, follow the instructions inside Table.pm.
The instructions are started with '###', three steps in total --
comment out two lines, uncomment one line.
Instructions in Table.pm looks like the following:
### comment out next line if your perl version < 5.005 ###
$r = ($caseIgn)?qr/$s/i : qr/$s/;
### comment out the next line if your perl version < 5.005
if ($elm =~ /$r/) {
### uncomment the next line if your perl version < 5.005
# if ($elm =~ /$s/ || ($elm=~ /$s/i && $caseIgn)) {
2. Others
# easydatabase@yahoo.com # this email account has been flooded by spam, please use below
easydatabase at gmail dot com
Data-Table-1.78/aaa.tsv 0000644 0054656 0001750 00000000563 13620555675 015217 0 ustar yzhou domain users Amino acid Entry Solvent Grams \"(a.a.)\"/100g sol. Temp, C Ref No.
Alanine 1 Ethanol 0.0087 25.0 1
L-aspartate 2 Ethanol 0.000196 25.0 2
L-glutamate 3 Ethanol 0.0056 44.93 2
Glycine 4 Ethanol 0.0037 25.0 1
L-allo-isoleucine 5 Ethanol 0.19 79 5
L-isoleucine 6 Ethanol 0.13 79 5
L-leucine 7 Ethanol 0.217 25.0 1
L-proline 8 Ethanol 1.5 19 6
Valiane 9 Ethanol 0.019 25.0 1
Data-Table-1.78/Changes 0000644 0054656 0001750 00000047505 13620555675 015241 0 ustar yzhou domain users Revision history for Perl extension Data::Table.
1.78 Tue Feb 11 08:44:44 PST 2020
Patch fromSQL to allow pre-executed handle
Patch provided by Jeff Janes
1.77 Wed Jan 23 14:02:24 PST 2019
No code change, add more examples under match_pattern_hash
Suggested by James Volkman
1.76 Tue Nov 21 08:08:30 PST 2017
Minor syntax bug in fromFile.
1.75 Sat Apr 23 13:52:25 PDT 2016
Patch parseCSV(). It returns incorrect columns when delimiter is space and has empty fields
Thanks to Jeff Janes for the fix.
1.74 Sun Mar 20 20:26:33 PDT 2016
Add wiki() and wiki2() return table in wikitable string
Suggested by Ruben Moretti
Modify html(), html2(), wiki(), wiki2() to support callback function,
which allows find control of tags within each individual cell
Passing color array ["","",""] will disable default color scheme.
1.73 Thu Mar 3 20:34:46 PST 2016
Some mionor typos in the document fixed. No code change.
Thanks to Lucas Kanashiro
1.72 Wed Apr 29 22:43:13 PDT 2015
No change to actual code Table.pm
Just comment out "Guess Windows file format" from t/test1.t, as Strawberry Perl swallows \r
and fails the test, however, this does not affect it to use the package
1.71
Fixed a minor bug in rename(), where the old name was not complete deleted.
The bug was triggered in rowMerge(byName=>1) + a very special situations.
Also fixed several typos in the test code.
A special thank to Alexandr Ciornii for help prepare new Makefile.PL,
as well as create better test files.
1.70 Sat Jan 25 06:44:12 PST 2014
Minor patch to 1.69, as encoding function is only reliably supported by Perl newer than v5.8.1.
Patch internal method openFileWithEncoding(), so that older Perl version will not give an error.
Fixed a warning in fromFileGuessOS, introduced in 1.69.
1.69 Tue Jan 14 10:22:19 PST 2014
Fix a minor bug in pivot() related to colToSplitIsStringOrNumeric.
Integer column names are allowed. However, fromFile by default does not take numeric
column names, unless allowNumericHeader is set to 1.
Patch fromFile(), checkHeader(), colIndex(), fromFileIsHeader(), fromFileGetTopLines()
to support numeric column header.
An integer is first interpreted as a column name. Therefore, accessing a column by its
ordinal number may not be possible, if the number is used as a column name. In such case,
first fetch the corresponding column name and access by name.
Support file encoding methods in fromFile, fromCSV, fromTSV.
E.g., fromCSV("filename, 1, undef, {encoding=> 'UTF-8'})
UTF-8 is the default encoding, can be controlled by $Data::Table::DEFAULTS{ENCODING}.
Thanks to questions asked by Sergio Basto and Thomas Hofmann.
If an integer is passed to colIndex(), it is interpreted as string first for column lookup.
fromFile by default will allow numeric headers (but not all column headers can be numeric).
support skip_empty in melt();
1.68 Mon Aug 6 22:22:22 PDT 2012
Patch fromFileGetTopLines() and fromFileIsHeader(), which are used by fromFile(). Impact: minor.
Improve performance of fromFileGuessOS()
Improve fromFile(), fromCSV(), csv() to support using \r, \n within a CSV field.
join() now supports {matchNULL => 1, NULLasEmpty => 1}, if one would like to treat NULL as empty string, or
treat NULL as equal (however, not equal to empty string). Both are set to 0 by default.
Suggested by Kyle Horton & Wilson Dave.
Remove inheritance from AutoLoader and Exporter.
Thanks to Brian Wightman
Thanks to Nicholas Andonakis for sharing his code, quite a few ideas in his package inspired the improvements below!
Add new shortcut methods: lastRow(), lastCol(), colName($colNumericIndex)
One can now write
foreach my $i (0..$t->lastRow)
instead of
foreach my $i (0..$t->nofRow-1)
Add iterator(), so that one can now write
my $next = $t_product->iterator();
while (my $row = $next->()) {
# have access to a row as a hash reference, access row number by &$next(1);
$t_product->setElm($next->(1), 'ProductName', 'New! '.$row->{ProductName});
}
addCol() can take the default value for the new column (first argument)
addRow() supports {addNewCol => 1}
moveCol() can take a $newColName.
setElm() can set a value for multiple cells, specified by ref to row array and col array
match_string(), match_pattern(), match_pattern_hash() also produce $parentTable->{MATCH}
# match returns all matched row ids in $t_product->{MATCH} (ref to row ID array)
$t_product->match_pattern_hash('$_{UnitPrice} > 20');
# create a new column, with 'No' as the default value
$t_product->addCol('No', 'IsExpensive');
# use $t_product->{MATCH} to set values for multiple Elements
$t_product->setElm($t_product->{MATCH}, 'IsExpensive', 'Yes');
1.67 Wed Jul 25 11:47:23 PDT 2012
Update Change.txt file to point out $keepRestCol defaults to 1 is only for group()
For pivot(), $keepRestCol is still default to 0 as before.
1.66 Wed Jul 25 11:03:29 PDT 2012
Change the default value of keepRestCol in group() to 1, instead of 0 to be compatible with older versions
Thanks to Kyle Horton
1.65 Mon Jul 23 20:16:08 PDT 2012
Finish the "Perl Data::Table Cookbook", should be a good learning material.
To download, visit https://sites.google.com/site/easydatabase/
Polish Data::Table::Excel for CPAN upload.
Minor patches to the code.
1.64 Sun Jul 8 22:01:17 PDT 2012
Add $keepRestCols to Data::Table::group();
We introduce new constants for fromCSV/fromTSV/fromFile/csv/tsv.
Data::Table::OS_UNIX = 0;
Data::Table::OS_PC = 1;
Data::Table::OS_MAC = 2;
Add method reorder(), redefine column orders
Add method melt() and cast(), concept borrowed from Reshape package in R
Add method each_group(), so one can apply a custom method to rows sharing the same key
Made a seemingly backward incompatible change to pivot()
pivot($colToSplit, $colToSplitIsNumeric, ...) is changed to
pivot($colToSplit, $colToSplitIsStringOrNumber, ...)
What is now pivot($colToSplit, $Data::Table::STRING, ...), where Data::Table::STRING has a value of 1,
was equivalent to pivot($colToSplit, 0, ...) in <= 1.63.
However, the $colToSplitIsStringOrNumber is now auto-guessed within the code, so the change is not very relevant.
Most existing code should run fine, without change.
Patch group(), piviot() to distinguish keys between empty string and undef.
Patch subTable() to take row mask array when {useRowMask=>1} is provided.
1.63 Tue Jun 12 17:05:43 PDT 2012
In this release, we patch addCol, delCol, addRow, rowMerge, colMerge to for an empty table
We introduce new methods isEmpty(), hasCol(), moveCol($colID, $newColIdx)
We introduce new constants for Data::Table::new()
Data::Table::ROW_BASED
Data::Table::COL_BASED
1.62 Fri May 25 11:40:09 PDT 2012
In this release, we address a few pain points
Data::Table::colMerge, update to support new options
{ renameCol => 1}
If specified, duplicate column names in the second table is automatically renamed (by appending _2) to avoid conflict
We introduce some constants, so we have fewer numbers to remember.
Data::Table::NUMBER
Data::Table::STRING
Data::Table::ASC
Data::Table::DESC
for sort(), you can use $t->sort('col2', Data::Table::NUMBER, Data::Table::DESC); it is equivalent to $t->sort('col2', 0, 1);
Data::Table::INNER_JOIN
Data::Table::LEFT_JOIN
Data::Table::RIGHT_JOIN
Data::Table::FULL_JOIN
for join(), you may use $t->sort($t2, Data::Table::FULL_JOIN, ['col1'], ['col1']);
it is equivalent to $t->sort($t2, 3, ['col1'], ['col1']).
match_string, match_pattern have been generating @Data::Table::OK, which is a class-level array.
$t->match_pattern() will now also store the results (array ref) in $t->{OK}, that should be used in the future.
However, @Data::Table::OK is still supported for compatibility reasons.
This is not a pain point, but conceptually nicer to be localized.
match_pattern_hash() is added. The difference is each row is fed to the pattern as a hash %_. In the case of
match_pattern, each row is fed as an array ref $_. The pattern for match_pattern_hash() becomes much cleaner.
If a table has two columns: Col_A as the 1st column and Col_B as the 2nd column, a filter "Col_A>2 AND Col_B<2"
is written before as
$t->match_pattern('$_->[0] > 2 && $_->[1] <2');
where we need to figure out $t->colIndex('Col_A') is 0 and $t->colIndex('Col_B') is 1, in order to build the pattern.
Now you can use column name directly in the pattern:
$t->match_pattern_hash('$_{Col_A} >2 && $_{Col_B} <2');
This method creates $t->{OK}, as well as @Data::Table::OK, same as match_pattern().
Data::Table::rowMerge, update to support new options
{ byName =>1, addNewCol => 1}
If byName is 1, rows in the second table are appended by matching their column names, so that the second table
can have columns in a different order.
If addNewCol is 1, columns not exist in the first table will be automatically added.
addNewCol is best used with byName. If used alone, addNewCol will just patch the two tables so that they have
the same number of columns.
Data::Table::subTable, update internal to remove side effect on column header array
Data::join add support for an option {renameCol => 1}.
If specified, duplicate column names in the second table is automatically renamed (by appending _2) to avoid conflict
1.61 Mon Feb 27 21:07:55 PST 2012
Data::Table::fromSQL now can take DBI::st instead of a SQL string. This is introduced, so that
variable binding (such as CLOB/BLOB) can be done outside the method.
1.60 Sat Feb 25 19:26:46 PST 2012
Data::Table::addRow now also can take a hash reference. Hash keys are column names,
undef will be the value, if a column name is not found in the hash.
Suggested by Federico
1.59 Sun Feb 5 00:20:00 PST 2012
I have never checked those CPAN ticket, happened to discover them and address them in this version.
Update document, explain Data::Table::fromCSV(\*STDIN, 1) can be used to read table from STDIN.
Add tbody and thead to Data::Table::html, if it's portrait.
Suggested by Ken Rosenberry.
Modify Data::Table::html and Data::Table::html2, so that it can accept coloring via CSS
The color now can be either specified as an array as before, or as three CSS class names
Suggested by Xavier Robin
1.58 Thu Feb 2 20:33:03 PST 2012
Patch join(), prior version of join considers two NULL keys to be equal
update document, clarify that rowMerge assumes table columns in the same order
Thanks to Ulrik Stervbo.
1.57 Thu Apr 23 15:22:36 PDT 2009
Patch pivot(), it throws warning before, when colToFill is undef.
1.56 Fri Aug 22 15:53:29 PDT 2008
When the first line in a TSV is not a header, but contains strings such as \t.
The program will not transform \t to a tab.
Modify fromTSV, so that \t, \N (etc) transformation is optional.
Add transform_element flag to fromTSV method to turn on/off the transformation.
Thanks to Bin Zhou.
1.55 Mon May 5 10:29:44 PDT 2008
Patch parseCSV. fromFile guesses the wrong delimiter if some ending columns are empty.
1.54 Sun Feb 10 21:35:02 PST 2008
Modify fromFileGetTopLines method, remove dependency on bytes
bytes::substr causes infinite loop in some older version of perl
Thanks to "eserte" for help in debugging.
1.53 Thu Jan 3 21:13:40 PST 2008
add "use bytes" to Table.pm
Just patched test.pl, because some OS cannot open in-memory file.
1.52 Fri Dec 14 11:48:42 PST 2007
1.51 Wed Dec 12 15:36:22 PST 2007
1. Add a class methods Data::Table::fromFile(file_name), which can
guess the file format and call fromCSV/fromTSV internally.
fromFile relies on the following new methods
fromFileGuessOS(file_name)
fromFileGetTopLines($file_name, $OS, $lineNumber)
fromFileIsHeader($string)
fromFileGuessDelimiter($arrayRefToLines)
to figure out if the input file is from UNIX/PC/MAC, whether its first
row contains column headers, and whether it uses ",", "\t" or ":" as
field delimiters.
It then calls either fromCSV or fromTSV to return the table object.
$t = Data::Table::fromFile("myFileName_CSVorTSV_HeaderOrNoHeader_UNIXorPCorMAC");
Please refers to the updated document for details.
2. When fromFile/fromCSV/fromTSV reads from an empty file, it returns
an undef object, rather than quit.
3. Provide more informative error message, when invalid column header is found.
4. fixed a bug in 1.51 where fromFileGuessOS failed in Windows
Thanks to patches provided by "whitebell".
1.50 Thu Sep 28 07:21:38 PDT 2006
Small modifications to sort subroutine example in the document, no bug.
join method, if $cols2 is undefined, defaults @$cols2 to @$cols1
Update fromCSV, fromTSV, csv methods to be able to deal with certain delimiters correctly.
(When the delimiter is a special symbol for regexp, it should be escaped, e.g., set delimiter to '\|' for pipe symbol).
Thanks to suggestions from Michael Slaven.
update fromCSV, fromTSV to take additional arguments: skip_lines and skip_pattern
skip_lines lets user skip several lines in the beginning of the input file
skip_pattern lets user skip all lines that match a regular expression
Please read documents under fromCSV and fromTSV for details.
Thanks to suggestions from Wenbin Ye.
1.49 Wed Aug 30 09:29:51 PDT 2006
Add %Data::Table::DEFAULTS to store the default settings for OS, CSV_DELIMITER and CSV_QUALIFIER
Thanks to suggestions from Roman Filippov
Patch sort method to deal with undef table element. undef value is considered to be
larger than any other value, two undef values are considered equal during sorting.
1.48 Thu Jun 8 13:25:54 PDT 2006
Update fromCSV, parseCSV to enable user-specified delimiter and qualifier,
see document and examples under fromCSV.
csvEscape is modified accordingly.
Thanks to help from Roman Filippov
1.47 Sun May 21 15:03:14 PDT 2006
Upload the wrong code in 1.46, re-upload
1.46 Sat May 13 05:44:09 PDT 2006
fromCSV, fromTSV, csv, tsv can all take either a file hander or a file name
Notice: to leave rooms for future development, file handler is not closed by Data::Table.
It's caller's responsibility to close it afterwards, if no longer used.
table::sort code is replaced, the old sort method is renamed to sort_v0 and is deprecated.
The new sort method allow user-defined sorting operators, please read manual on table::sort
The new sort method also runs faster in some benchmark tests.
A big thank to Wenbin Ye for suggestions, as well as contributing
both the new sort code and test examples
1.45 Mon May 1 09:08:20 PDT 2006
Fix a bug in fromTSV
last column name is truncated by one character (introduced in 1.44)
Thanks to Albert V. Smith
1.44 Sat Apr 15 04:27:28 PDT 2006
Fix a bug in join (type=2 and 3)
When right or full join, key fields are undef for right-only entries.
modify fromCSV, fromTSV, tsv, csv subroutines to support read/write PC, Mac and UNIX files.
csv and tsv can take a file name and directly writes to it.
1.43 Tue Nov 9 10:23:44 PST 2004
Patch html so that valid XHTML code is generated
Several mispelled words were corrected
Thanks all to Wolfgang Dautermann
1.42 Fri Oct 8 11:56:41 PDT 2004
Minor changes to group and pivot, not a bug
1.41 Thu Oct 7 14:04:17 CDT 2004
Add two useful methods: group and pivot
group can make the records unique based on given key columns
pivot is handy to transfer database table into a more user readable format
group+pivot make accounting operations easy, please read the document for details.
Due to the spam, please use the following for email contact
easydatabase at gmail dot com
1.40 Wed Oct 15 12:11:11 CDT 2003
Patch colMap, as suggested by Jeff Janes
1.39 Wed Mar 26 09:33:01 CST 2003
Fix a bug in match_pattern, match_string and row_mask;
When a new table was created by these methods, deleting columns had a
side effect of the original parent table.
1.38 Sun Jan 19 18:26:23 CST 2003
Change die to croak as suggested by Jeff Janes.
1.37 Tue Sep 17 17:53:55 CDT 2002
Add $countOnly to match_string and match_pattern, thanks to Serge Batalov.
1.36 Thu Sep 12 14:47:59 CDT 2002
Add close() to both fromTSV and fromCSV, thanks to Brian Coon.
1.35 Mon Jul 1 13:04:43 PDT 2002
Optimization in parseCSV, thanks to Jeff Janes.
1.34 Wed May 1 12:13:33 CDT 2002
Fix a bug in colMerge
1.33 Wed Jan 16 17:55:34 CST 2002
Small patches to join method. Not a bug.
Thanks to Xiao-Jun Ma
1.32 Sun Sep 30 16:21:02 CDT 2001
No change, just update Table.html (forgot in version 1.31)
1.31 Wed Sep 20 21:22:22 PDT 2001
add colsMap($fun), which does more than colMap can;
Unlike colMap, $fun here have access to multiple columns.
Read document for details.
1.30 Wed Sep 19 20:02:52 PDT 2001
Improve header method, which can now take a new header argument.
Improve fromTSV and fromCSV, which now can take the 3rd argument --
if header is supplied, it will always be used (despite the 2nd argument).
Read document for details.
Fix a bug in adding a new column to a empty table.
Thanks to Serge Batalov.
1.29 Mon Sep 17 18:18:13 CDT 2001
a bug fixed in fromTSV
The first line was skipped when header==0 is specified in fromTSV.
1.28 Wed Sep 5 17:59:36 CDT 2001
a bug fixed in fromCSV, where \c or \\ apears in the file.
Fix provided by Jeff Janes.
1.27 Mon Jul 9 00:04:54 PDT 2001
accept more formatting parameters for html, combine html2 with html.
1.26 Mon May 21 09:35:41 PDT 2001
A typo bug in swap fixed
Thanks to Jeff Janes
1.25 Thu May 3 00:50:03 PDT 2001
add BEGIN, check perl version, update README.
We realize Table.pm requires 5.005 at least.
See README for the patch for older perl.
Thanks to Jeffery Cann
1.24 Sat Apr 21 20:30:18 PDT 2001
a bug in match_pattern fixed (important!)
Thanks to Robson Francisco de Souza
1.23 Thu Apr 12 14:36:45 PDT 2001
a bug in html, html2 fixed, where table element "" displayed ugly
introduced in version 1.21
1.22 Sat Mar 25 14:30:06 PST 2001
join method added
support four join types: inner, left outer, right outer, and full outer.
a small bug in html2 fixed, thanks to Fred Lovine
1.21 Fri Mar 9 21:04:30 PST 2001
rowMask method added
A bug in html, html2 fixed, where table element 0 is not displayed
Thanks to Sven Neuhaus
1.20 Wed Feb 28 12:38:53 PST 2001
A bug in match_string is fixed.
This will affect results if you change your "string" value in the program;
Also add a caseIgnore control argument to match_string method.
Thanks to Bryan Coon.
1.19 Sat Feb 24 23:23:37 PST 2001
A bug in fromSQL is fixed (caused by typo)
This happens when user use the third argument (a reference to an array).
The old package will show an error message in some cases.
Add $header option for csv and tsv, output header or not
Add the following instant methods
fromSQLi
fromCSVi
fromTSVi
so that these methods can be inherited.
Thanks to Michael Schlueter
Update new method, so that it can be used as an instant method as well.
Add method
rowHashRef
which returns a copy of a table row in hash reference.
Officially support TSV format via the following three methods
Data::Table::fromTSV
fromTSVi
tsv
Read "TSV FORMAT" section for details.
1.18
Fix the problem in Data::Table::fromCSV caused by null trailing fields.
E.g., a line "a,b,," in a csv file was split into two fields before.
Thanks to Karsten
Fix the warning message in Data::Table::match_string, when table contains
an undef element.
Add Data::Table::fromTSV and Data::Table:tsv
TSV - tab-deliminated file format. TSV preserves NULL element and line-break
chars in a table.
\0, \\, \r, \b, \n, \t are slash-escaped.
undef is escaped into \N.
This is based on MySQL specification.
1.16 Fri Sep 29 22:18:06 PDT 2000
Package name changed from Table to Data::Table, due to
name collision with PerlQt
first official release version
1.15 Tue Sep 26 18:32:52 PDT 2000
submitted to CPAN
Data-Table-1.78/t_dos.csv 0000644 0054656 0001750 00000000025 13620555675 015555 0 ustar yzhou domain users a,b,c
1,2,3
4,5,6
Data-Table-1.78/Makefile.old 0000644 0054656 0001750 00000064705 13620555675 016164 0 ustar yzhou domain users # This Makefile is for the Data::Table extension to perl.
#
# It was generated automatically by MakeMaker version
# 6.72 (Revision: 67200) from the contents of
# Makefile.PL. Don't edit this file, edit Makefile.PL instead.
#
# ANY CHANGES MADE HERE WILL BE LOST!
#
# MakeMaker ARGV: ()
#
# MakeMaker Parameters:
# ABSTRACT_FROM => q[Table.pm]
# BUILD_REQUIRES => { }
# CONFIGURE_REQUIRES => { }
# LICENSE => q[perl]
# META_MERGE => { resources=>{ } }
# MIN_PERL_VERSION => q[5.006]
# NAME => q[Data::Table]
# PREREQ_PM => { Test::More=>q[0], Carp=>q[0] }
# TEST_REQUIRES => { Test::More=>q[0] }
# VERSION_FROM => q[Table.pm]
# --- MakeMaker post_initialize section:
# --- MakeMaker const_config section:
# These definitions are from config.sh (via /tools/GNU/perl/5.14.2/lib/5.14.2/x86_64-linux/Config.pm).
# They may have been overridden via Makefile.PL or on the command line.
AR = ar
CC = cc
CCCDLFLAGS = -fPIC
CCDLFLAGS = -Wl,-E
DLEXT = so
DLSRC = dl_dlopen.xs
EXE_EXT =
FULL_AR = /usr/bin/ar
LD = cc
LDDLFLAGS = -shared -O2 -L/usr/local/lib -fstack-protector
LDFLAGS = -fstack-protector -L/usr/local/lib
LIBC = /lib/libc-2.11.1.so
LIB_EXT = .a
OBJ_EXT = .o
OSNAME = linux
OSVERS = 2.6.32.36-0.5-default
RANLIB = :
SITELIBEXP = /tools/GNU/perl/5.14.2/lib/site_perl/5.14.2
SITEARCHEXP = /tools/GNU/perl/5.14.2/lib/site_perl/5.14.2/x86_64-linux
SO = so
VENDORARCHEXP =
VENDORLIBEXP =
# --- MakeMaker constants section:
AR_STATIC_ARGS = cr
DIRFILESEP = /
DFSEP = $(DIRFILESEP)
NAME = Data::Table
NAME_SYM = Data_Table
VERSION = 1.74
VERSION_MACRO = VERSION
VERSION_SYM = 1_74
DEFINE_VERSION = -D$(VERSION_MACRO)=\"$(VERSION)\"
XS_VERSION = 1.74
XS_VERSION_MACRO = XS_VERSION
XS_DEFINE_VERSION = -D$(XS_VERSION_MACRO)=\"$(XS_VERSION)\"
INST_ARCHLIB = blib/arch
INST_SCRIPT = blib/script
INST_BIN = blib/bin
INST_LIB = blib/lib
INST_MAN1DIR = blib/man1
INST_MAN3DIR = blib/man3
MAN1EXT = 1
MAN3EXT = 3
INSTALLDIRS = site
DESTDIR =
PREFIX = $(SITEPREFIX)
PERLPREFIX = /tools/GNU/perl/5.14.2
SITEPREFIX = /tools/GNU/perl/5.14.2
VENDORPREFIX =
INSTALLPRIVLIB = /tools/GNU/perl/5.14.2/lib/5.14.2
DESTINSTALLPRIVLIB = $(DESTDIR)$(INSTALLPRIVLIB)
INSTALLSITELIB = /tools/GNU/perl/5.14.2/lib/site_perl/5.14.2
DESTINSTALLSITELIB = $(DESTDIR)$(INSTALLSITELIB)
INSTALLVENDORLIB =
DESTINSTALLVENDORLIB = $(DESTDIR)$(INSTALLVENDORLIB)
INSTALLARCHLIB = /tools/GNU/perl/5.14.2/lib/5.14.2/x86_64-linux
DESTINSTALLARCHLIB = $(DESTDIR)$(INSTALLARCHLIB)
INSTALLSITEARCH = /tools/GNU/perl/5.14.2/lib/site_perl/5.14.2/x86_64-linux
DESTINSTALLSITEARCH = $(DESTDIR)$(INSTALLSITEARCH)
INSTALLVENDORARCH =
DESTINSTALLVENDORARCH = $(DESTDIR)$(INSTALLVENDORARCH)
INSTALLBIN = /tools/GNU/perl/5.14.2/bin
DESTINSTALLBIN = $(DESTDIR)$(INSTALLBIN)
INSTALLSITEBIN = /tools/GNU/perl/5.14.2/bin
DESTINSTALLSITEBIN = $(DESTDIR)$(INSTALLSITEBIN)
INSTALLVENDORBIN =
DESTINSTALLVENDORBIN = $(DESTDIR)$(INSTALLVENDORBIN)
INSTALLSCRIPT = /tools/GNU/perl/5.14.2/bin
DESTINSTALLSCRIPT = $(DESTDIR)$(INSTALLSCRIPT)
INSTALLSITESCRIPT = /tools/GNU/perl/5.14.2/bin
DESTINSTALLSITESCRIPT = $(DESTDIR)$(INSTALLSITESCRIPT)
INSTALLVENDORSCRIPT =
DESTINSTALLVENDORSCRIPT = $(DESTDIR)$(INSTALLVENDORSCRIPT)
INSTALLMAN1DIR = /tools/GNU/perl/5.14.2/man/man1
DESTINSTALLMAN1DIR = $(DESTDIR)$(INSTALLMAN1DIR)
INSTALLSITEMAN1DIR = /tools/GNU/perl/5.14.2/man/man1
DESTINSTALLSITEMAN1DIR = $(DESTDIR)$(INSTALLSITEMAN1DIR)
INSTALLVENDORMAN1DIR =
DESTINSTALLVENDORMAN1DIR = $(DESTDIR)$(INSTALLVENDORMAN1DIR)
INSTALLMAN3DIR = /tools/GNU/perl/5.14.2/man/man3
DESTINSTALLMAN3DIR = $(DESTDIR)$(INSTALLMAN3DIR)
INSTALLSITEMAN3DIR = /tools/GNU/perl/5.14.2/man/man3
DESTINSTALLSITEMAN3DIR = $(DESTDIR)$(INSTALLSITEMAN3DIR)
INSTALLVENDORMAN3DIR =
DESTINSTALLVENDORMAN3DIR = $(DESTDIR)$(INSTALLVENDORMAN3DIR)
PERL_LIB = /tools/GNU/perl/5.14.2/lib/5.14.2
PERL_ARCHLIB = /tools/GNU/perl/5.14.2/lib/5.14.2/x86_64-linux
LIBPERL_A = libperl.a
FIRST_MAKEFILE = Makefile
MAKEFILE_OLD = Makefile.old
MAKE_APERL_FILE = Makefile.aperl
PERLMAINCC = $(CC)
PERL_INC = /tools/GNU/perl/5.14.2/lib/5.14.2/x86_64-linux/CORE
PERL = /.automount/tools/GNU/perl/5.14.2/bin/perl
FULLPERL = /.automount/tools/GNU/perl/5.14.2/bin/perl
ABSPERL = $(PERL)
PERLRUN = $(PERL)
FULLPERLRUN = $(FULLPERL)
ABSPERLRUN = $(ABSPERL)
PERLRUNINST = $(PERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)"
FULLPERLRUNINST = $(FULLPERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)"
ABSPERLRUNINST = $(ABSPERLRUN) "-I$(INST_ARCHLIB)" "-I$(INST_LIB)"
PERL_CORE = 0
PERM_DIR = 755
PERM_RW = 644
PERM_RWX = 755
MAKEMAKER = /tools/GNU/perl/5.14.2/lib/site_perl/5.14.2/ExtUtils/MakeMaker.pm
MM_VERSION = 6.72
MM_REVISION = 67200
# FULLEXT = Pathname for extension directory (eg Foo/Bar/Oracle).
# BASEEXT = Basename part of FULLEXT. May be just equal FULLEXT. (eg Oracle)
# PARENT_NAME = NAME without BASEEXT and no trailing :: (eg Foo::Bar)
# DLBASE = Basename part of dynamic library. May be just equal BASEEXT.
MAKE = make
FULLEXT = Data/Table
BASEEXT = Table
PARENT_NAME = Data
DLBASE = $(BASEEXT)
VERSION_FROM = Table.pm
OBJECT =
LDFROM = $(OBJECT)
LINKTYPE = dynamic
BOOTDEP =
# Handy lists of source code files:
XS_FILES =
C_FILES =
O_FILES =
H_FILES =
MAN1PODS =
MAN3PODS = Table.pm
# Where is the Config information that we are using/depend on
CONFIGDEP = $(PERL_ARCHLIB)$(DFSEP)Config.pm $(PERL_INC)$(DFSEP)config.h
# Where to build things
INST_LIBDIR = $(INST_LIB)/Data
INST_ARCHLIBDIR = $(INST_ARCHLIB)/Data
INST_AUTODIR = $(INST_LIB)/auto/$(FULLEXT)
INST_ARCHAUTODIR = $(INST_ARCHLIB)/auto/$(FULLEXT)
INST_STATIC =
INST_DYNAMIC =
INST_BOOT =
# Extra linker info
EXPORT_LIST =
PERL_ARCHIVE =
PERL_ARCHIVE_AFTER =
TO_INST_PM = Table.pm
PM_TO_BLIB = Table.pm \
$(INST_LIB)/Data/Table.pm
# --- MakeMaker platform_constants section:
MM_Unix_VERSION = 6.72
PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc
# --- MakeMaker tool_autosplit section:
# Usage: $(AUTOSPLITFILE) FileToSplit AutoDirToSplitInto
AUTOSPLITFILE = $(ABSPERLRUN) -e 'use AutoSplit; autosplit($$$$ARGV[0], $$$$ARGV[1], 0, 1, 1)' --
# --- MakeMaker tool_xsubpp section:
# --- MakeMaker tools_other section:
SHELL = /bin/sh
CHMOD = chmod
CP = cp
MV = mv
NOOP = $(TRUE)
NOECHO = @
RM_F = rm -f
RM_RF = rm -rf
TEST_F = test -f
TOUCH = touch
UMASK_NULL = umask 0
DEV_NULL = > /dev/null 2>&1
MKPATH = $(ABSPERLRUN) -MExtUtils::Command -e 'mkpath' --
EQUALIZE_TIMESTAMP = $(ABSPERLRUN) -MExtUtils::Command -e 'eqtime' --
FALSE = false
TRUE = true
ECHO = echo
ECHO_N = echo -n
UNINST = 0
VERBINST = 0
MOD_INSTALL = $(ABSPERLRUN) -MExtUtils::Install -e 'install([ from_to => {@ARGV}, verbose => '\''$(VERBINST)'\'', uninstall_shadows => '\''$(UNINST)'\'', dir_mode => '\''$(PERM_DIR)'\'' ]);' --
DOC_INSTALL = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'perllocal_install' --
UNINSTALL = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'uninstall' --
WARN_IF_OLD_PACKLIST = $(ABSPERLRUN) -MExtUtils::Command::MM -e 'warn_if_old_packlist' --
MACROSTART =
MACROEND =
USEMAKEFILE = -f
FIXIN = $(ABSPERLRUN) -MExtUtils::MY -e 'MY->fixin(shift)' --
# --- MakeMaker makemakerdflt section:
makemakerdflt : all
$(NOECHO) $(NOOP)
# --- MakeMaker dist section:
TAR = tar
TARFLAGS = cvf
ZIP = zip
ZIPFLAGS = -r
COMPRESS = gzip --best
SUFFIX = .gz
SHAR = shar
PREOP = $(NOECHO) $(NOOP)
POSTOP = $(NOECHO) $(NOOP)
TO_UNIX = $(NOECHO) $(NOOP)
CI = ci -u
RCS_LABEL = rcs -Nv$(VERSION_SYM): -q
DIST_CP = best
DIST_DEFAULT = tardist
DISTNAME = Data-Table
DISTVNAME = Data-Table-1.74
# --- MakeMaker macro section:
# --- MakeMaker depend section:
# --- MakeMaker cflags section:
# --- MakeMaker const_loadlibs section:
# --- MakeMaker const_cccmd section:
# --- MakeMaker post_constants section:
# --- MakeMaker pasthru section:
PASTHRU = LIBPERL_A="$(LIBPERL_A)"\
LINKTYPE="$(LINKTYPE)"\
PREFIX="$(PREFIX)"
# --- MakeMaker special_targets section:
.SUFFIXES : .xs .c .C .cpp .i .s .cxx .cc $(OBJ_EXT)
.PHONY: all config static dynamic test linkext manifest blibdirs clean realclean disttest distdir
# --- MakeMaker c_o section:
# --- MakeMaker xs_c section:
# --- MakeMaker xs_o section:
# --- MakeMaker top_targets section:
all :: pure_all manifypods
$(NOECHO) $(NOOP)
pure_all :: config pm_to_blib subdirs linkext
$(NOECHO) $(NOOP)
subdirs :: $(MYEXTLIB)
$(NOECHO) $(NOOP)
config :: $(FIRST_MAKEFILE) blibdirs
$(NOECHO) $(NOOP)
help :
perldoc ExtUtils::MakeMaker
# --- MakeMaker blibdirs section:
blibdirs : $(INST_LIBDIR)$(DFSEP).exists $(INST_ARCHLIB)$(DFSEP).exists $(INST_AUTODIR)$(DFSEP).exists $(INST_ARCHAUTODIR)$(DFSEP).exists $(INST_BIN)$(DFSEP).exists $(INST_SCRIPT)$(DFSEP).exists $(INST_MAN1DIR)$(DFSEP).exists $(INST_MAN3DIR)$(DFSEP).exists
$(NOECHO) $(NOOP)
# Backwards compat with 6.18 through 6.25
blibdirs.ts : blibdirs
$(NOECHO) $(NOOP)
$(INST_LIBDIR)$(DFSEP).exists :: Makefile.PL
$(NOECHO) $(MKPATH) $(INST_LIBDIR)
$(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_LIBDIR)
$(NOECHO) $(TOUCH) $(INST_LIBDIR)$(DFSEP).exists
$(INST_ARCHLIB)$(DFSEP).exists :: Makefile.PL
$(NOECHO) $(MKPATH) $(INST_ARCHLIB)
$(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_ARCHLIB)
$(NOECHO) $(TOUCH) $(INST_ARCHLIB)$(DFSEP).exists
$(INST_AUTODIR)$(DFSEP).exists :: Makefile.PL
$(NOECHO) $(MKPATH) $(INST_AUTODIR)
$(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_AUTODIR)
$(NOECHO) $(TOUCH) $(INST_AUTODIR)$(DFSEP).exists
$(INST_ARCHAUTODIR)$(DFSEP).exists :: Makefile.PL
$(NOECHO) $(MKPATH) $(INST_ARCHAUTODIR)
$(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_ARCHAUTODIR)
$(NOECHO) $(TOUCH) $(INST_ARCHAUTODIR)$(DFSEP).exists
$(INST_BIN)$(DFSEP).exists :: Makefile.PL
$(NOECHO) $(MKPATH) $(INST_BIN)
$(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_BIN)
$(NOECHO) $(TOUCH) $(INST_BIN)$(DFSEP).exists
$(INST_SCRIPT)$(DFSEP).exists :: Makefile.PL
$(NOECHO) $(MKPATH) $(INST_SCRIPT)
$(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_SCRIPT)
$(NOECHO) $(TOUCH) $(INST_SCRIPT)$(DFSEP).exists
$(INST_MAN1DIR)$(DFSEP).exists :: Makefile.PL
$(NOECHO) $(MKPATH) $(INST_MAN1DIR)
$(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_MAN1DIR)
$(NOECHO) $(TOUCH) $(INST_MAN1DIR)$(DFSEP).exists
$(INST_MAN3DIR)$(DFSEP).exists :: Makefile.PL
$(NOECHO) $(MKPATH) $(INST_MAN3DIR)
$(NOECHO) $(CHMOD) $(PERM_DIR) $(INST_MAN3DIR)
$(NOECHO) $(TOUCH) $(INST_MAN3DIR)$(DFSEP).exists
# --- MakeMaker linkext section:
linkext :: $(LINKTYPE)
$(NOECHO) $(NOOP)
# --- MakeMaker dlsyms section:
# --- MakeMaker dynamic section:
dynamic :: $(FIRST_MAKEFILE) $(INST_DYNAMIC) $(INST_BOOT)
$(NOECHO) $(NOOP)
# --- MakeMaker dynamic_bs section:
BOOTSTRAP =
# --- MakeMaker dynamic_lib section:
# --- MakeMaker static section:
## $(INST_PM) has been moved to the all: target.
## It remains here for awhile to allow for old usage: "make static"
static :: $(FIRST_MAKEFILE) $(INST_STATIC)
$(NOECHO) $(NOOP)
# --- MakeMaker static_lib section:
# --- MakeMaker manifypods section:
POD2MAN_EXE = $(PERLRUN) "-MExtUtils::Command::MM" -e pod2man "--"
POD2MAN = $(POD2MAN_EXE)
manifypods : pure_all \
Table.pm
$(NOECHO) $(POD2MAN) --section=3 --perm_rw=$(PERM_RW) \
Table.pm $(INST_MAN3DIR)/Data::Table.$(MAN3EXT)
# --- MakeMaker processPL section:
# --- MakeMaker installbin section:
# --- MakeMaker subdirs section:
# none
# --- MakeMaker clean_subdirs section:
clean_subdirs :
$(NOECHO) $(NOOP)
# --- MakeMaker clean section:
# Delete temporary files but do not touch installed files. We don't delete
# the Makefile here so a later make realclean still has a makefile to use.
clean :: clean_subdirs
- $(RM_F) \
*$(LIB_EXT) core \
core.[0-9] $(INST_ARCHAUTODIR)/extralibs.all \
core.[0-9][0-9] $(BASEEXT).bso \
pm_to_blib.ts MYMETA.json \
core.[0-9][0-9][0-9][0-9] MYMETA.yml \
$(BASEEXT).x $(BOOTSTRAP) \
perl$(EXE_EXT) tmon.out \
*$(OBJ_EXT) pm_to_blib \
$(INST_ARCHAUTODIR)/extralibs.ld blibdirs.ts \
core.[0-9][0-9][0-9][0-9][0-9] *perl.core \
core.*perl.*.? $(MAKE_APERL_FILE) \
$(BASEEXT).def perl \
core.[0-9][0-9][0-9] mon.out \
lib$(BASEEXT).def perlmain.c \
perl.exe so_locations \
$(BASEEXT).exp
- $(RM_RF) \
blib
- $(NOECHO) $(RM_F) $(MAKEFILE_OLD)
- $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD) $(DEV_NULL)
# --- MakeMaker realclean_subdirs section:
realclean_subdirs :
$(NOECHO) $(NOOP)
# --- MakeMaker realclean section:
# Delete temporary files (via clean) and also delete dist files
realclean purge :: clean realclean_subdirs
- $(RM_F) \
$(MAKEFILE_OLD) $(FIRST_MAKEFILE)
- $(RM_RF) \
$(DISTVNAME)
# --- MakeMaker metafile section:
metafile : create_distdir
$(NOECHO) $(ECHO) Generating META.yml
$(NOECHO) $(ECHO) '---' > META_new.yml
$(NOECHO) $(ECHO) 'abstract: '\''Data type related to database tables, spreadsheets, CSV/TSV files, HTML table displays, etc.'\''' >> META_new.yml
$(NOECHO) $(ECHO) 'author:' >> META_new.yml
$(NOECHO) $(ECHO) ' - unknown' >> META_new.yml
$(NOECHO) $(ECHO) 'build_requires:' >> META_new.yml
$(NOECHO) $(ECHO) ' ExtUtils::MakeMaker: 0' >> META_new.yml
$(NOECHO) $(ECHO) ' Test::More: 0' >> META_new.yml
$(NOECHO) $(ECHO) 'configure_requires:' >> META_new.yml
$(NOECHO) $(ECHO) ' ExtUtils::MakeMaker: 0' >> META_new.yml
$(NOECHO) $(ECHO) 'dynamic_config: 1' >> META_new.yml
$(NOECHO) $(ECHO) 'generated_by: '\''ExtUtils::MakeMaker version 6.72, CPAN::Meta::Converter version 2.120351'\''' >> META_new.yml
$(NOECHO) $(ECHO) 'license: perl' >> META_new.yml
$(NOECHO) $(ECHO) 'meta-spec:' >> META_new.yml
$(NOECHO) $(ECHO) ' url: http://module-build.sourceforge.net/META-spec-v1.4.html' >> META_new.yml
$(NOECHO) $(ECHO) ' version: 1.4' >> META_new.yml
$(NOECHO) $(ECHO) 'name: Data-Table' >> META_new.yml
$(NOECHO) $(ECHO) 'no_index:' >> META_new.yml
$(NOECHO) $(ECHO) ' directory:' >> META_new.yml
$(NOECHO) $(ECHO) ' - t' >> META_new.yml
$(NOECHO) $(ECHO) ' - inc' >> META_new.yml
$(NOECHO) $(ECHO) 'requires:' >> META_new.yml
$(NOECHO) $(ECHO) ' Carp: 0' >> META_new.yml
$(NOECHO) $(ECHO) ' perl: 5.006' >> META_new.yml
$(NOECHO) $(ECHO) 'resources: {}' >> META_new.yml
$(NOECHO) $(ECHO) 'version: 1.74' >> META_new.yml
-$(NOECHO) $(MV) META_new.yml $(DISTVNAME)/META.yml
$(NOECHO) $(ECHO) Generating META.json
$(NOECHO) $(ECHO) '{' > META_new.json
$(NOECHO) $(ECHO) ' "abstract" : "Data type related to database tables, spreadsheets, CSV/TSV files, HTML table displays, etc.",' >> META_new.json
$(NOECHO) $(ECHO) ' "author" : [' >> META_new.json
$(NOECHO) $(ECHO) ' "unknown"' >> META_new.json
$(NOECHO) $(ECHO) ' ],' >> META_new.json
$(NOECHO) $(ECHO) ' "dynamic_config" : 1,' >> META_new.json
$(NOECHO) $(ECHO) ' "generated_by" : "ExtUtils::MakeMaker version 6.72, CPAN::Meta::Converter version 2.120351",' >> META_new.json
$(NOECHO) $(ECHO) ' "license" : [' >> META_new.json
$(NOECHO) $(ECHO) ' "perl_5"' >> META_new.json
$(NOECHO) $(ECHO) ' ],' >> META_new.json
$(NOECHO) $(ECHO) ' "meta-spec" : {' >> META_new.json
$(NOECHO) $(ECHO) ' "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",' >> META_new.json
$(NOECHO) $(ECHO) ' "version" : "2"' >> META_new.json
$(NOECHO) $(ECHO) ' },' >> META_new.json
$(NOECHO) $(ECHO) ' "name" : "Data-Table",' >> META_new.json
$(NOECHO) $(ECHO) ' "no_index" : {' >> META_new.json
$(NOECHO) $(ECHO) ' "directory" : [' >> META_new.json
$(NOECHO) $(ECHO) ' "t",' >> META_new.json
$(NOECHO) $(ECHO) ' "inc"' >> META_new.json
$(NOECHO) $(ECHO) ' ]' >> META_new.json
$(NOECHO) $(ECHO) ' },' >> META_new.json
$(NOECHO) $(ECHO) ' "prereqs" : {' >> META_new.json
$(NOECHO) $(ECHO) ' "build" : {' >> META_new.json
$(NOECHO) $(ECHO) ' "requires" : {' >> META_new.json
$(NOECHO) $(ECHO) ' "ExtUtils::MakeMaker" : "0",' >> META_new.json
$(NOECHO) $(ECHO) ' "Test::More" : "0"' >> META_new.json
$(NOECHO) $(ECHO) ' }' >> META_new.json
$(NOECHO) $(ECHO) ' },' >> META_new.json
$(NOECHO) $(ECHO) ' "configure" : {' >> META_new.json
$(NOECHO) $(ECHO) ' "requires" : {' >> META_new.json
$(NOECHO) $(ECHO) ' "ExtUtils::MakeMaker" : "0"' >> META_new.json
$(NOECHO) $(ECHO) ' }' >> META_new.json
$(NOECHO) $(ECHO) ' },' >> META_new.json
$(NOECHO) $(ECHO) ' "runtime" : {' >> META_new.json
$(NOECHO) $(ECHO) ' "requires" : {' >> META_new.json
$(NOECHO) $(ECHO) ' "Carp" : "0",' >> META_new.json
$(NOECHO) $(ECHO) ' "perl" : "5.006"' >> META_new.json
$(NOECHO) $(ECHO) ' }' >> META_new.json
$(NOECHO) $(ECHO) ' }' >> META_new.json
$(NOECHO) $(ECHO) ' },' >> META_new.json
$(NOECHO) $(ECHO) ' "release_status" : "stable",' >> META_new.json
$(NOECHO) $(ECHO) ' "resources" : {},' >> META_new.json
$(NOECHO) $(ECHO) ' "version" : "1.74"' >> META_new.json
$(NOECHO) $(ECHO) '}' >> META_new.json
-$(NOECHO) $(MV) META_new.json $(DISTVNAME)/META.json
# --- MakeMaker signature section:
signature :
cpansign -s
# --- MakeMaker dist_basics section:
distclean :: realclean distcheck
$(NOECHO) $(NOOP)
distcheck :
$(PERLRUN) "-MExtUtils::Manifest=fullcheck" -e fullcheck
skipcheck :
$(PERLRUN) "-MExtUtils::Manifest=skipcheck" -e skipcheck
manifest :
$(PERLRUN) "-MExtUtils::Manifest=mkmanifest" -e mkmanifest
veryclean : realclean
$(RM_F) *~ */*~ *.orig */*.orig *.bak */*.bak *.old */*.old
# --- MakeMaker dist_core section:
dist : $(DIST_DEFAULT) $(FIRST_MAKEFILE)
$(NOECHO) $(ABSPERLRUN) -l -e 'print '\''Warning: Makefile possibly out of date with $(VERSION_FROM)'\''' \
-e ' if -e '\''$(VERSION_FROM)'\'' and -M '\''$(VERSION_FROM)'\'' < -M '\''$(FIRST_MAKEFILE)'\'';' --
tardist : $(DISTVNAME).tar$(SUFFIX)
$(NOECHO) $(NOOP)
uutardist : $(DISTVNAME).tar$(SUFFIX)
uuencode $(DISTVNAME).tar$(SUFFIX) $(DISTVNAME).tar$(SUFFIX) > $(DISTVNAME).tar$(SUFFIX)_uu
$(NOECHO) $(ECHO) 'Created $(DISTVNAME).tar$(SUFFIX)_uu'
$(DISTVNAME).tar$(SUFFIX) : distdir
$(PREOP)
$(TO_UNIX)
$(TAR) $(TARFLAGS) $(DISTVNAME).tar $(DISTVNAME)
$(RM_RF) $(DISTVNAME)
$(COMPRESS) $(DISTVNAME).tar
$(NOECHO) $(ECHO) 'Created $(DISTVNAME).tar$(SUFFIX)'
$(POSTOP)
zipdist : $(DISTVNAME).zip
$(NOECHO) $(NOOP)
$(DISTVNAME).zip : distdir
$(PREOP)
$(ZIP) $(ZIPFLAGS) $(DISTVNAME).zip $(DISTVNAME)
$(RM_RF) $(DISTVNAME)
$(NOECHO) $(ECHO) 'Created $(DISTVNAME).zip'
$(POSTOP)
shdist : distdir
$(PREOP)
$(SHAR) $(DISTVNAME) > $(DISTVNAME).shar
$(RM_RF) $(DISTVNAME)
$(NOECHO) $(ECHO) 'Created $(DISTVNAME).shar'
$(POSTOP)
# --- MakeMaker distdir section:
create_distdir :
$(RM_RF) $(DISTVNAME)
$(PERLRUN) "-MExtUtils::Manifest=manicopy,maniread" \
-e "manicopy(maniread(),'$(DISTVNAME)', '$(DIST_CP)');"
distdir : create_distdir distmeta
$(NOECHO) $(NOOP)
# --- MakeMaker dist_test section:
disttest : distdir
cd $(DISTVNAME) && $(ABSPERLRUN) Makefile.PL
cd $(DISTVNAME) && $(MAKE) $(PASTHRU)
cd $(DISTVNAME) && $(MAKE) test $(PASTHRU)
# --- MakeMaker dist_ci section:
ci :
$(PERLRUN) "-MExtUtils::Manifest=maniread" \
-e "@all = keys %{ maniread() };" \
-e "print(qq{Executing $(CI) @all\n}); system(qq{$(CI) @all});" \
-e "print(qq{Executing $(RCS_LABEL) ...\n}); system(qq{$(RCS_LABEL) @all});"
# --- MakeMaker distmeta section:
distmeta : create_distdir metafile
$(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'exit unless -e q{META.yml};' \
-e 'eval { maniadd({q{META.yml} => q{Module YAML meta-data (added by MakeMaker)}}) }' \
-e ' or print "Could not add META.yml to MANIFEST: $$$${'\''@'\''}\n"' --
$(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'exit unless -f q{META.json};' \
-e 'eval { maniadd({q{META.json} => q{Module JSON meta-data (added by MakeMaker)}}) }' \
-e ' or print "Could not add META.json to MANIFEST: $$$${'\''@'\''}\n"' --
# --- MakeMaker distsignature section:
distsignature : create_distdir
$(NOECHO) cd $(DISTVNAME) && $(ABSPERLRUN) -MExtUtils::Manifest=maniadd -e 'eval { maniadd({q{SIGNATURE} => q{Public-key signature (added by MakeMaker)}}) }' \
-e ' or print "Could not add SIGNATURE to MANIFEST: $$$${'\''@'\''}\n"' --
$(NOECHO) cd $(DISTVNAME) && $(TOUCH) SIGNATURE
cd $(DISTVNAME) && cpansign -s
# --- MakeMaker install section:
install :: pure_install doc_install
$(NOECHO) $(NOOP)
install_perl :: pure_perl_install doc_perl_install
$(NOECHO) $(NOOP)
install_site :: pure_site_install doc_site_install
$(NOECHO) $(NOOP)
install_vendor :: pure_vendor_install doc_vendor_install
$(NOECHO) $(NOOP)
pure_install :: pure_$(INSTALLDIRS)_install
$(NOECHO) $(NOOP)
doc_install :: doc_$(INSTALLDIRS)_install
$(NOECHO) $(NOOP)
pure__install : pure_site_install
$(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
doc__install : doc_site_install
$(NOECHO) $(ECHO) INSTALLDIRS not defined, defaulting to INSTALLDIRS=site
pure_perl_install :: all
$(NOECHO) $(MOD_INSTALL) \
read $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist \
write $(DESTINSTALLARCHLIB)/auto/$(FULLEXT)/.packlist \
$(INST_LIB) $(DESTINSTALLPRIVLIB) \
$(INST_ARCHLIB) $(DESTINSTALLARCHLIB) \
$(INST_BIN) $(DESTINSTALLBIN) \
$(INST_SCRIPT) $(DESTINSTALLSCRIPT) \
$(INST_MAN1DIR) $(DESTINSTALLMAN1DIR) \
$(INST_MAN3DIR) $(DESTINSTALLMAN3DIR)
$(NOECHO) $(WARN_IF_OLD_PACKLIST) \
$(SITEARCHEXP)/auto/$(FULLEXT)
pure_site_install :: all
$(NOECHO) $(MOD_INSTALL) \
read $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist \
write $(DESTINSTALLSITEARCH)/auto/$(FULLEXT)/.packlist \
$(INST_LIB) $(DESTINSTALLSITELIB) \
$(INST_ARCHLIB) $(DESTINSTALLSITEARCH) \
$(INST_BIN) $(DESTINSTALLSITEBIN) \
$(INST_SCRIPT) $(DESTINSTALLSITESCRIPT) \
$(INST_MAN1DIR) $(DESTINSTALLSITEMAN1DIR) \
$(INST_MAN3DIR) $(DESTINSTALLSITEMAN3DIR)
$(NOECHO) $(WARN_IF_OLD_PACKLIST) \
$(PERL_ARCHLIB)/auto/$(FULLEXT)
pure_vendor_install :: all
$(NOECHO) $(MOD_INSTALL) \
read $(VENDORARCHEXP)/auto/$(FULLEXT)/.packlist \
write $(DESTINSTALLVENDORARCH)/auto/$(FULLEXT)/.packlist \
$(INST_LIB) $(DESTINSTALLVENDORLIB) \
$(INST_ARCHLIB) $(DESTINSTALLVENDORARCH) \
$(INST_BIN) $(DESTINSTALLVENDORBIN) \
$(INST_SCRIPT) $(DESTINSTALLVENDORSCRIPT) \
$(INST_MAN1DIR) $(DESTINSTALLVENDORMAN1DIR) \
$(INST_MAN3DIR) $(DESTINSTALLVENDORMAN3DIR)
doc_perl_install :: all
$(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
-$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
-$(NOECHO) $(DOC_INSTALL) \
"Module" "$(NAME)" \
"installed into" "$(INSTALLPRIVLIB)" \
LINKTYPE "$(LINKTYPE)" \
VERSION "$(VERSION)" \
EXE_FILES "$(EXE_FILES)" \
>> $(DESTINSTALLARCHLIB)/perllocal.pod
doc_site_install :: all
$(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
-$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
-$(NOECHO) $(DOC_INSTALL) \
"Module" "$(NAME)" \
"installed into" "$(INSTALLSITELIB)" \
LINKTYPE "$(LINKTYPE)" \
VERSION "$(VERSION)" \
EXE_FILES "$(EXE_FILES)" \
>> $(DESTINSTALLARCHLIB)/perllocal.pod
doc_vendor_install :: all
$(NOECHO) $(ECHO) Appending installation info to $(DESTINSTALLARCHLIB)/perllocal.pod
-$(NOECHO) $(MKPATH) $(DESTINSTALLARCHLIB)
-$(NOECHO) $(DOC_INSTALL) \
"Module" "$(NAME)" \
"installed into" "$(INSTALLVENDORLIB)" \
LINKTYPE "$(LINKTYPE)" \
VERSION "$(VERSION)" \
EXE_FILES "$(EXE_FILES)" \
>> $(DESTINSTALLARCHLIB)/perllocal.pod
uninstall :: uninstall_from_$(INSTALLDIRS)dirs
$(NOECHO) $(NOOP)
uninstall_from_perldirs ::
$(NOECHO) $(UNINSTALL) $(PERL_ARCHLIB)/auto/$(FULLEXT)/.packlist
uninstall_from_sitedirs ::
$(NOECHO) $(UNINSTALL) $(SITEARCHEXP)/auto/$(FULLEXT)/.packlist
uninstall_from_vendordirs ::
$(NOECHO) $(UNINSTALL) $(VENDORARCHEXP)/auto/$(FULLEXT)/.packlist
# --- MakeMaker force section:
# Phony target to force checking subdirectories.
FORCE :
$(NOECHO) $(NOOP)
# --- MakeMaker perldepend section:
# --- MakeMaker makefile section:
# We take a very conservative approach here, but it's worth it.
# We move Makefile to Makefile.old here to avoid gnu make looping.
$(FIRST_MAKEFILE) : Makefile.PL $(CONFIGDEP)
$(NOECHO) $(ECHO) "Makefile out-of-date with respect to $?"
$(NOECHO) $(ECHO) "Cleaning current config before rebuilding Makefile..."
-$(NOECHO) $(RM_F) $(MAKEFILE_OLD)
-$(NOECHO) $(MV) $(FIRST_MAKEFILE) $(MAKEFILE_OLD)
- $(MAKE) $(USEMAKEFILE) $(MAKEFILE_OLD) clean $(DEV_NULL)
$(PERLRUN) Makefile.PL
$(NOECHO) $(ECHO) "==> Your Makefile has been rebuilt. <=="
$(NOECHO) $(ECHO) "==> Please rerun the $(MAKE) command. <=="
$(FALSE)
# --- MakeMaker staticmake section:
# --- MakeMaker makeaperl section ---
MAP_TARGET = perl
FULLPERL = /.automount/tools/GNU/perl/5.14.2/bin/perl
$(MAP_TARGET) :: static $(MAKE_APERL_FILE)
$(MAKE) $(USEMAKEFILE) $(MAKE_APERL_FILE) $@
$(MAKE_APERL_FILE) : $(FIRST_MAKEFILE) pm_to_blib
$(NOECHO) $(ECHO) Writing \"$(MAKE_APERL_FILE)\" for this $(MAP_TARGET)
$(NOECHO) $(PERLRUNINST) \
Makefile.PL DIR= \
MAKEFILE=$(MAKE_APERL_FILE) LINKTYPE=static \
MAKEAPERL=1 NORECURS=1 CCCDLFLAGS=
# --- MakeMaker test section:
TEST_VERBOSE=0
TEST_TYPE=test_$(LINKTYPE)
TEST_FILE = test.pl
TEST_FILES = t/*.t
TESTDB_SW = -d
testdb :: testdb_$(LINKTYPE)
test :: $(TEST_TYPE) subdirs-test
subdirs-test ::
$(NOECHO) $(NOOP)
test_dynamic :: pure_all
PERL_DL_NONLAZY=1 $(FULLPERLRUN) "-MExtUtils::Command::MM" "-e" "test_harness($(TEST_VERBOSE), '$(INST_LIB)', '$(INST_ARCHLIB)')" $(TEST_FILES)
testdb_dynamic :: pure_all
PERL_DL_NONLAZY=1 $(FULLPERLRUN) $(TESTDB_SW) "-I$(INST_LIB)" "-I$(INST_ARCHLIB)" $(TEST_FILE)
test_ : test_dynamic
test_static :: test_dynamic
testdb_static :: testdb_dynamic
# --- MakeMaker ppd section:
# Creates a PPD (Perl Package Description) for a binary distribution.
ppd :
$(NOECHO) $(ECHO) '($callback->({%$tag_th}, -1, $i, $header->[$i], $self)) : $s_th) .">".$header->[$i]." | \n"; } $s .="||
---|---|---|
":" | "; $s .= (defined($data->[$i][$j]) && $data->[$i][$j] ne '')?$data->[$i][$j]:" "; $s .= " | \n"; } $s .= "|
($callback->({%$tag_th_def}, -1, $i, $header->[$i], $self)) : $s_th) .">". $header->[$i] . " | \n"; my $td_def = $tag_td->{$i} || $tag_td->{$header->[$i]} || {}; $td_def = {'' => $td_def} unless ref $td_def; for (my $j=0; $j<=$#{$data->[0]}; $j++) { my $td = {}; if ($l_colorByClass) { $td->{"class"}=$CELL_CLASSES[$j%2] if $CELL_CLASSES[$j%2]; } else { $td->{"style"}="background-color:".$BG_COLOR[$j%2].";" if $BG_COLOR[$j%2]; } $merge_tag->($td, $td_def); my $s_td=$tag2str->($cb ? $callback->({%$td}, $j, $i, $header->[$i], $self) : $td) || ""; $s .= ($s_td)? "":" | "; $s .= (defined($data->[$i][$j]) && $data->[$i][$j] ne '')?$data->[$i][$j]:' '; $s .= " | \n"; } $s .= "