Debian Codegraph @

Changes

raw
1 Revision history for Perl extension Data::Table.
2
3 1.78 Tue Feb 11 08:44:44 PST 2020
4 Patch fromSQL to allow pre-executed handle
5 Patch provided by Jeff Janes
6
7 1.77 Wed Jan 23 14:02:24 PST 2019
8 No code change, add more examples under match_pattern_hash
9 Suggested by James Volkman
10
11 1.76 Tue Nov 21 08:08:30 PST 2017
12 Minor syntax bug in fromFile.
13
14 1.75 Sat Apr 23 13:52:25 PDT 2016
15 Patch parseCSV(). It returns incorrect columns when delimiter is space and has empty fields
16 Thanks to Jeff Janes for the fix.
17
18 1.74 Sun Mar 20 20:26:33 PDT 2016
19 Add wiki() and wiki2() return table in wikitable string
20 Suggested by Ruben Moretti
21
22 Modify html(), html2(), wiki(), wiki2() to support callback function,
23 which allows find control of tags within each individual cell
24 Passing color array ["","",""] will disable default color scheme.
25
26 1.73 Thu Mar 3 20:34:46 PST 2016
27 Some mionor typos in the document fixed. No code change.
28 Thanks to Lucas Kanashiro
29
30 1.72 Wed Apr 29 22:43:13 PDT 2015
31 No change to actual code Table.pm
32 Just comment out "Guess Windows file format" from t/test1.t, as Strawberry Perl swallows \r
33 and fails the test, however, this does not affect it to use the package
34
35 1.71
36 Fixed a minor bug in rename(), where the old name was not complete deleted.
37 The bug was triggered in rowMerge(byName=>1) + a very special situations.
38 Also fixed several typos in the test code.
39
40 A special thank to Alexandr Ciornii for help prepare new Makefile.PL,
41 as well as create better test files.
42
43 1.70 Sat Jan 25 06:44:12 PST 2014
44 Minor patch to 1.69, as encoding function is only reliably supported by Perl newer than v5.8.1.
45 Patch internal method openFileWithEncoding(), so that older Perl version will not give an error.
46
47 Fixed a warning in fromFileGuessOS, introduced in 1.69.
48
49 1.69 Tue Jan 14 10:22:19 PST 2014
50
51 Fix a minor bug in pivot() related to colToSplitIsStringOrNumeric.
52
53 Integer column names are allowed. However, fromFile by default does not take numeric
54 column names, unless allowNumericHeader is set to 1.
55 Patch fromFile(), checkHeader(), colIndex(), fromFileIsHeader(), fromFileGetTopLines()
56 to support numeric column header.
57 An integer is first interpreted as a column name. Therefore, accessing a column by its
58 ordinal number may not be possible, if the number is used as a column name. In such case,
59 first fetch the corresponding column name and access by name.
60
61 Support file encoding methods in fromFile, fromCSV, fromTSV.
62 E.g., fromCSV("filename, 1, undef, {encoding=> 'UTF-8'})
63 UTF-8 is the default encoding, can be controlled by $Data::Table::DEFAULTS{ENCODING}.
64 Thanks to questions asked by Sergio Basto and Thomas Hofmann.
65
66 If an integer is passed to colIndex(), it is interpreted as string first for column lookup.
67 fromFile by default will allow numeric headers (but not all column headers can be numeric).
68
69 support skip_empty in melt();
70
71 1.68 Mon Aug 6 22:22:22 PDT 2012
72
73 Patch fromFileGetTopLines() and fromFileIsHeader(), which are used by fromFile(). Impact: minor.
74 Improve performance of fromFileGuessOS()
75 Improve fromFile(), fromCSV(), csv() to support using \r, \n within a CSV field.
76
77 join() now supports {matchNULL => 1, NULLasEmpty => 1}, if one would like to treat NULL as empty string, or
78 treat NULL as equal (however, not equal to empty string). Both are set to 0 by default.
79 Suggested by Kyle Horton & Wilson Dave.
80
81 Remove inheritance from AutoLoader and Exporter.
82 Thanks to Brian Wightman
83
84 Thanks to Nicholas Andonakis for sharing his code, quite a few ideas in his package inspired the improvements below!
85
86 Add new shortcut methods: lastRow(), lastCol(), colName($colNumericIndex)
87 One can now write
88 foreach my $i (0..$t->lastRow)
89 instead of
90 foreach my $i (0..$t->nofRow-1)
91
92 Add iterator(), so that one can now write
93 my $next = $t_product->iterator();
94 while (my $row = $next->()) {
95 # have access to a row as a hash reference, access row number by &$next(1);
96 $t_product->setElm($next->(1), 'ProductName', 'New! '.$row->{ProductName});
97 }
98
99 addCol() can take the default value for the new column (first argument)
100 addRow() supports {addNewCol => 1}
101 moveCol() can take a $newColName.
102
103 setElm() can set a value for multiple cells, specified by ref to row array and col array
104 match_string(), match_pattern(), match_pattern_hash() also produce $parentTable->{MATCH}
105
106 # match returns all matched row ids in $t_product->{MATCH} (ref to row ID array)
107 $t_product->match_pattern_hash('$_{UnitPrice} > 20');
108 # create a new column, with 'No' as the default value
109 $t_product->addCol('No', 'IsExpensive');
110 # use $t_product->{MATCH} to set values for multiple Elements
111 $t_product->setElm($t_product->{MATCH}, 'IsExpensive', 'Yes');
112
113 1.67 Wed Jul 25 11:47:23 PDT 2012
114 Update Change.txt file to point out $keepRestCol defaults to 1 is only for group()
115 For pivot(), $keepRestCol is still default to 0 as before.
116
117 1.66 Wed Jul 25 11:03:29 PDT 2012
118 Change the default value of keepRestCol in group() to 1, instead of 0 to be compatible with older versions
119 Thanks to Kyle Horton
120
121 1.65 Mon Jul 23 20:16:08 PDT 2012
122 Finish the "Perl Data::Table Cookbook", should be a good learning material.
123 To download, visit https://sites.google.com/site/easydatabase/
124
125 Polish Data::Table::Excel for CPAN upload.
126
127 Minor patches to the code.
128
129 1.64 Sun Jul 8 22:01:17 PDT 2012
130 Add $keepRestCols to Data::Table::group();
131 We introduce new constants for fromCSV/fromTSV/fromFile/csv/tsv.
132 Data::Table::OS_UNIX = 0;
133 Data::Table::OS_PC = 1;
134 Data::Table::OS_MAC = 2;
135 Add method reorder(), redefine column orders
136 Add method melt() and cast(), concept borrowed from Reshape package in R
137 Add method each_group(), so one can apply a custom method to rows sharing the same key
138
139 Made a seemingly backward incompatible change to pivot()
140 pivot($colToSplit, $colToSplitIsNumeric, ...) is changed to
141 pivot($colToSplit, $colToSplitIsStringOrNumber, ...)
142 What is now pivot($colToSplit, $Data::Table::STRING, ...), where Data::Table::STRING has a value of 1,
143 was equivalent to pivot($colToSplit, 0, ...) in <= 1.63.
144 However, the $colToSplitIsStringOrNumber is now auto-guessed within the code, so the change is not very relevant.
145 Most existing code should run fine, without change.
146
147 Patch group(), piviot() to distinguish keys between empty string and undef.
148
149 Patch subTable() to take row mask array when {useRowMask=>1} is provided.
150
151 1.63 Tue Jun 12 17:05:43 PDT 2012
152 In this release, we patch addCol, delCol, addRow, rowMerge, colMerge to for an empty table
153 We introduce new methods isEmpty(), hasCol(), moveCol($colID, $newColIdx)
154 We introduce new constants for Data::Table::new()
155 Data::Table::ROW_BASED
156 Data::Table::COL_BASED
157
158 1.62 Fri May 25 11:40:09 PDT 2012
159 In this release, we address a few pain points
160
161 Data::Table::colMerge, update to support new options
162 { renameCol => 1}
163 If specified, duplicate column names in the second table is automatically renamed (by appending _2) to avoid conflict
164
165 We introduce some constants, so we have fewer numbers to remember.
166 Data::Table::NUMBER
167 Data::Table::STRING
168 Data::Table::ASC
169 Data::Table::DESC
170
171 for sort(), you can use $t->sort('col2', Data::Table::NUMBER, Data::Table::DESC); it is equivalent to $t->sort('col2', 0, 1);
172
173 Data::Table::INNER_JOIN
174 Data::Table::LEFT_JOIN
175 Data::Table::RIGHT_JOIN
176 Data::Table::FULL_JOIN
177
178 for join(), you may use $t->sort($t2, Data::Table::FULL_JOIN, ['col1'], ['col1']);
179 it is equivalent to $t->sort($t2, 3, ['col1'], ['col1']).
180
181 match_string, match_pattern have been generating @Data::Table::OK, which is a class-level array.
182 $t->match_pattern() will now also store the results (array ref) in $t->{OK}, that should be used in the future.
183 However, @Data::Table::OK is still supported for compatibility reasons.
184 This is not a pain point, but conceptually nicer to be localized.
185
186 match_pattern_hash() is added. The difference is each row is fed to the pattern as a hash %_. In the case of
187 match_pattern, each row is fed as an array ref $_. The pattern for match_pattern_hash() becomes much cleaner.
188 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"
189 is written before as
190 $t->match_pattern('$_->[0] > 2 && $_->[1] <2');
191 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.
192 Now you can use column name directly in the pattern:
193 $t->match_pattern_hash('$_{Col_A} >2 && $_{Col_B} <2');
194 This method creates $t->{OK}, as well as @Data::Table::OK, same as match_pattern().
195
196 Data::Table::rowMerge, update to support new options
197 { byName =>1, addNewCol => 1}
198 If byName is 1, rows in the second table are appended by matching their column names, so that the second table
199 can have columns in a different order.
200 If addNewCol is 1, columns not exist in the first table will be automatically added.
201 addNewCol is best used with byName. If used alone, addNewCol will just patch the two tables so that they have
202 the same number of columns.
203 Data::Table::subTable, update internal to remove side effect on column header array
204 Data::join add support for an option {renameCol => 1}.
205 If specified, duplicate column names in the second table is automatically renamed (by appending _2) to avoid conflict
206
207 1.61 Mon Feb 27 21:07:55 PST 2012
208 Data::Table::fromSQL now can take DBI::st instead of a SQL string. This is introduced, so that
209 variable binding (such as CLOB/BLOB) can be done outside the method.
210
211 1.60 Sat Feb 25 19:26:46 PST 2012
212 Data::Table::addRow now also can take a hash reference. Hash keys are column names,
213 undef will be the value, if a column name is not found in the hash.
214 Suggested by Federico
215
216 1.59 Sun Feb 5 00:20:00 PST 2012
217 I have never checked those CPAN ticket, happened to discover them and address them in this version.
218 Update document, explain Data::Table::fromCSV(\*STDIN, 1) can be used to read table from STDIN.
219 Add tbody and thead to Data::Table::html, if it's portrait.
220 Suggested by Ken Rosenberry.
221 Modify Data::Table::html and Data::Table::html2, so that it can accept coloring via CSS
222 The color now can be either specified as an array as before, or as three CSS class names
223 Suggested by Xavier Robin
224
225 1.58 Thu Feb 2 20:33:03 PST 2012
226 Patch join(), prior version of join considers two NULL keys to be equal
227 update document, clarify that rowMerge assumes table columns in the same order
228 Thanks to Ulrik Stervbo.
229
230 1.57 Thu Apr 23 15:22:36 PDT 2009
231 Patch pivot(), it throws warning before, when colToFill is undef.
232
233 1.56 Fri Aug 22 15:53:29 PDT 2008
234 When the first line in a TSV is not a header, but contains strings such as \t.
235 The program will not transform \t to a tab.
236 Modify fromTSV, so that \t, \N (etc) transformation is optional.
237 Add transform_element flag to fromTSV method to turn on/off the transformation.
238 Thanks to Bin Zhou.
239
240 1.55 Mon May 5 10:29:44 PDT 2008
241 Patch parseCSV. fromFile guesses the wrong delimiter if some ending columns are empty.
242
243 1.54 Sun Feb 10 21:35:02 PST 2008
244 Modify fromFileGetTopLines method, remove dependency on bytes
245 bytes::substr causes infinite loop in some older version of perl
246 Thanks to "eserte" for help in debugging.
247
248 1.53 Thu Jan 3 21:13:40 PST 2008
249 add "use bytes" to Table.pm
250 Just patched test.pl, because some OS cannot open in-memory file.
251
252 1.52 Fri Dec 14 11:48:42 PST 2007
253 1.51 Wed Dec 12 15:36:22 PST 2007
254 1. Add a class methods Data::Table::fromFile(file_name), which can
255 guess the file format and call fromCSV/fromTSV internally.
256
257 fromFile relies on the following new methods
258 fromFileGuessOS(file_name)
259 fromFileGetTopLines($file_name, $OS, $lineNumber)
260 fromFileIsHeader($string)
261 fromFileGuessDelimiter($arrayRefToLines)
262 to figure out if the input file is from UNIX/PC/MAC, whether its first
263 row contains column headers, and whether it uses ",", "\t" or ":" as
264 field delimiters.
265 It then calls either fromCSV or fromTSV to return the table object.
266
267 $t = Data::Table::fromFile("myFileName_CSVorTSV_HeaderOrNoHeader_UNIXorPCorMAC");
268
269 Please refers to the updated document for details.
270
271 2. When fromFile/fromCSV/fromTSV reads from an empty file, it returns
272 an undef object, rather than quit.
273
274 3. Provide more informative error message, when invalid column header is found.
275
276 4. fixed a bug in 1.51 where fromFileGuessOS failed in Windows
277 Thanks to patches provided by "whitebell".
278
279 1.50 Thu Sep 28 07:21:38 PDT 2006
280 Small modifications to sort subroutine example in the document, no bug.
281
282 join method, if $cols2 is undefined, defaults @$cols2 to @$cols1
283 Update fromCSV, fromTSV, csv methods to be able to deal with certain delimiters correctly.
284 (When the delimiter is a special symbol for regexp, it should be escaped, e.g., set delimiter to '\|' for pipe symbol).
285 Thanks to suggestions from Michael Slaven.
286
287 update fromCSV, fromTSV to take additional arguments: skip_lines and skip_pattern
288 skip_lines lets user skip several lines in the beginning of the input file
289 skip_pattern lets user skip all lines that match a regular expression
290 Please read documents under fromCSV and fromTSV for details.
291 Thanks to suggestions from Wenbin Ye.
292
293 1.49 Wed Aug 30 09:29:51 PDT 2006
294 Add %Data::Table::DEFAULTS to store the default settings for OS, CSV_DELIMITER and CSV_QUALIFIER
295 Thanks to suggestions from Roman Filippov
296
297 Patch sort method to deal with undef table element. undef value is considered to be
298 larger than any other value, two undef values are considered equal during sorting.
299
300 1.48 Thu Jun 8 13:25:54 PDT 2006
301 Update fromCSV, parseCSV to enable user-specified delimiter and qualifier,
302 see document and examples under fromCSV.
303 csvEscape is modified accordingly.
304 Thanks to help from Roman Filippov
305
306 1.47 Sun May 21 15:03:14 PDT 2006
307 Upload the wrong code in 1.46, re-upload
308
309 1.46 Sat May 13 05:44:09 PDT 2006
310 fromCSV, fromTSV, csv, tsv can all take either a file hander or a file name
311 Notice: to leave rooms for future development, file handler is not closed by Data::Table.
312 It's caller's responsibility to close it afterwards, if no longer used.
313 table::sort code is replaced, the old sort method is renamed to sort_v0 and is deprecated.
314 The new sort method allow user-defined sorting operators, please read manual on table::sort
315 The new sort method also runs faster in some benchmark tests.
316 A big thank to Wenbin Ye for suggestions, as well as contributing
317 both the new sort code and test examples
318
319 1.45 Mon May 1 09:08:20 PDT 2006
320 Fix a bug in fromTSV
321 last column name is truncated by one character (introduced in 1.44)
322 Thanks to Albert V. Smith
323
324 1.44 Sat Apr 15 04:27:28 PDT 2006
325 Fix a bug in join (type=2 and 3)
326 When right or full join, key fields are undef for right-only entries.
327
328 modify fromCSV, fromTSV, tsv, csv subroutines to support read/write PC, Mac and UNIX files.
329 csv and tsv can take a file name and directly writes to it.
330
331 1.43 Tue Nov 9 10:23:44 PST 2004
332 Patch html so that valid XHTML code is generated
333 Several mispelled words were corrected
334 Thanks all to Wolfgang Dautermann
335
336 1.42 Fri Oct 8 11:56:41 PDT 2004
337 Minor changes to group and pivot, not a bug
338
339 1.41 Thu Oct 7 14:04:17 CDT 2004
340 Add two useful methods: group and pivot
341 group can make the records unique based on given key columns
342 pivot is handy to transfer database table into a more user readable format
343 group+pivot make accounting operations easy, please read the document for details.
344
345 Due to the spam, please use the following for email contact
346 easydatabase at gmail dot com
347
348 1.40 Wed Oct 15 12:11:11 CDT 2003
349 Patch colMap, as suggested by Jeff Janes
350
351 1.39 Wed Mar 26 09:33:01 CST 2003
352 Fix a bug in match_pattern, match_string and row_mask;
353 When a new table was created by these methods, deleting columns had a
354 side effect of the original parent table.
355
356 1.38 Sun Jan 19 18:26:23 CST 2003
357 Change die to croak as suggested by Jeff Janes.
358
359 1.37 Tue Sep 17 17:53:55 CDT 2002
360 Add $countOnly to match_string and match_pattern, thanks to Serge Batalov.
361
362 1.36 Thu Sep 12 14:47:59 CDT 2002
363 Add close() to both fromTSV and fromCSV, thanks to Brian Coon.
364
365 1.35 Mon Jul 1 13:04:43 PDT 2002
366 Optimization in parseCSV, thanks to Jeff Janes.
367
368 1.34 Wed May 1 12:13:33 CDT 2002
369 Fix a bug in colMerge
370
371 1.33 Wed Jan 16 17:55:34 CST 2002
372 Small patches to join method. Not a bug.
373 Thanks to Xiao-Jun Ma
374
375 1.32 Sun Sep 30 16:21:02 CDT 2001
376 No change, just update Table.html (forgot in version 1.31)
377
378 1.31 Wed Sep 20 21:22:22 PDT 2001
379 add colsMap($fun), which does more than colMap can;
380 Unlike colMap, $fun here have access to multiple columns.
381 Read document for details.
382
383 1.30 Wed Sep 19 20:02:52 PDT 2001
384 Improve header method, which can now take a new header argument.
385 Improve fromTSV and fromCSV, which now can take the 3rd argument --
386 if header is supplied, it will always be used (despite the 2nd argument).
387 Read document for details.
388 Fix a bug in adding a new column to a empty table.
389 Thanks to Serge Batalov.
390
391 1.29 Mon Sep 17 18:18:13 CDT 2001
392 a bug fixed in fromTSV
393 The first line was skipped when header==0 is specified in fromTSV.
394
395 1.28 Wed Sep 5 17:59:36 CDT 2001
396 a bug fixed in fromCSV, where \c or \\ apears in the file.
397 Fix provided by Jeff Janes.
398
399 1.27 Mon Jul 9 00:04:54 PDT 2001
400 accept more formatting parameters for html, combine html2 with html.
401
402 1.26 Mon May 21 09:35:41 PDT 2001
403 A typo bug in swap fixed
404 Thanks to Jeff Janes
405
406 1.25 Thu May 3 00:50:03 PDT 2001
407 add BEGIN, check perl version, update README.
408 We realize Table.pm requires 5.005 at least.
409 See README for the patch for older perl.
410 Thanks to Jeffery Cann
411
412 1.24 Sat Apr 21 20:30:18 PDT 2001
413 a bug in match_pattern fixed (important!)
414 Thanks to Robson Francisco de Souza
415
416 1.23 Thu Apr 12 14:36:45 PDT 2001
417 a bug in html, html2 fixed, where table element "" displayed ugly
418 introduced in version 1.21
419
420 1.22 Sat Mar 25 14:30:06 PST 2001
421 join method added
422 support four join types: inner, left outer, right outer, and full outer.
423
424 a small bug in html2 fixed, thanks to Fred Lovine
425
426 1.21 Fri Mar 9 21:04:30 PST 2001
427 rowMask method added
428
429 A bug in html, html2 fixed, where table element 0 is not displayed
430 Thanks to Sven Neuhaus
431
432 1.20 Wed Feb 28 12:38:53 PST 2001
433 A bug in match_string is fixed.
434 This will affect results if you change your "string" value in the program;
435 Also add a caseIgnore control argument to match_string method.
436 Thanks to Bryan Coon.
437
438 1.19 Sat Feb 24 23:23:37 PST 2001
439 A bug in fromSQL is fixed (caused by typo)
440 This happens when user use the third argument (a reference to an array).
441 The old package will show an error message in some cases.
442
443 Add $header option for csv and tsv, output header or not
444
445 Add the following instant methods
446 fromSQLi
447 fromCSVi
448 fromTSVi
449 so that these methods can be inherited.
450 Thanks to Michael Schlueter
451
452 Update new method, so that it can be used as an instant method as well.
453
454 Add method
455 rowHashRef
456 which returns a copy of a table row in hash reference.
457
458 Officially support TSV format via the following three methods
459 Data::Table::fromTSV
460 fromTSVi
461 tsv
462 Read "TSV FORMAT" section for details.
463
464 1.18
465 Fix the problem in Data::Table::fromCSV caused by null trailing fields.
466 E.g., a line "a,b,," in a csv file was split into two fields before.
467 Thanks to Karsten
468
469 Fix the warning message in Data::Table::match_string, when table contains
470 an undef element.
471
472 Add Data::Table::fromTSV and Data::Table:tsv
473 TSV - tab-deliminated file format. TSV preserves NULL element and line-break
474 chars in a table.
475 \0, \\, \r, \b, \n, \t are slash-escaped.
476 undef is escaped into \N.
477 This is based on MySQL specification.
478
479 1.16 Fri Sep 29 22:18:06 PDT 2000
480 Package name changed from Table to Data::Table, due to
481 name collision with PerlQt
482 first official release version
483
484 1.15 Tue Sep 26 18:32:52 PDT 2000
485 submitted to CPAN