Data-TableReader-0.022 000755 001750 001750 0 15234670244 16264 5 ustar 00silverdirk silverdirk 000000 000000 README 100644 001750 001750 626 15234670244 17211 0 ustar 00silverdirk silverdirk 000000 000000 Data-TableReader-0.022 This archive contains the distribution Data-TableReader,
version 0.022:
Locate and read records from human-edited data tables (Excel, CSV)
This software is copyright (c) 2026 by Michael Conrad.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
This README file was generated by Dist::Zilla::Plugin::Readme v6.036.
Changes 100644 001750 001750 13471 15234670244 17666 0 ustar 00silverdirk silverdirk 000000 000000 Data-TableReader-0.022 Version 0.022 - 2026-08-05
- Support various web framework Upload objects being used as ->input
- Use content_type if available in preference to file extension or
content heuristics.
- Differentiate between real_file_name and client_file_name, and ignore
the file extension of real_file_name if client_file_name exists.
(e.g. things broke when Catalyst changed the file extension to .upload)
These show as new attributes on the Decoder.
- Much improved detection and handling of charset for CSV, TSV, and HTML
- Properly handle consequences of writes to the ->fields(...) attribute
by clearing other attributes.
- Fix several col_map lifecycle bugs: preserve the caller's original
array, restore the supplied map after clearing search results, re-resolve
it after fields change, and avoid reusing a previous search result during
subsequent find_table calls.
- Fix bug when using ->seek on a record iterator which had reached EOF
or was in the middle of counting blank lines.
- Fix ability to use ->all on a record iterator where record objects could
stringify to a false value.
- More API validation and better error messages in a variety of edge cases.
- Stop logging at 'notice' level since it isn't supported by all common
logger objects.
- Fix numerous documentation mistakes, including callback argument list of
on_partial_match and on_unknown_columns.
- Additionally pass the %candidate structure to on_unknown_columns callback.
Version 0.021 - 2024-05-02
- Use ->table_search_results->{...}{row} instead of {row_idx}
- Allow initializing TableReader 'fields' attribute with Field objects
(had only been allowing strings and hashrefs)
- Decoder::Mock now correctly handles empty tables (no rows)
Version 0.020 - 2024-04-30
- Rename on_validation_fail -> on_validation_error
The action codes are the same, but the callback has different arguments.
Old callbacks applied using the attribute name 'on_validation_fail' will
continue to work.
- New iterator attribute 'dataset_idx', for keeping track of which dataset
you're on.
- Unimplemented Iterator->seek now dies as per the documentation.
(no built-in iterator lacked support for seek, so unlikely to matter)
Version 0.015 - 2024-04-27
- Better support for fields sharing name, with Field->addr (refaddr) and
TableReader->field_by_addr
- Decoder iterators now have ->row attribute
- Spreadsheet decoder ->position includes sheet number and now uses
1-based row number (as originally intended)
- Results of find_table are stored in table_search_results for better
inspection and reporting on a failure. This allows detection messages
to be associated with a row, and various conflicts to be associated with
a column (without parsing message text).
- On a failed find_table, user can inspect the attempts in
table_search_results->{candidates} and select one to be ->{found}, and
then proceed to create the iterator.
- col_map is now a full attribute and can be specified in the constructor.
find_table starts with the user-supplied value and tries to fill in any
'undef' values in that array.
- New settings on_partial_match, on_ambiguous_columns, and modified
official values of on_unknown_columns. These provide better control
over what counts as an error and whether to continue the search.
Version 0.014 - 2024-03-25
- Fix compatibility with newest Spreadsheet::ParseXLSX
Version 0.013 - 2024-03-22
- Fix bug in unit tests causing failure when MRO::Compat not installed
Version 0.012 - 2024-03-07
- Field now has 'coerce' attribute which can be a coderef, or enable
Type::Tiny coercion.
- TableReader 'input' attribute can now be an arrayref, as a shorthand
for the 'Mock' decoder.
- Improved unit tests
Version 0.011 - 2019-06-27
- Allow per-field 'trim' value to be a regex or coderef
- Change dist version-munger to Dist::Zilla::Plugin::OurPkgVersion
- Exclude ::Decoder::HTML files from getting shipped with main dist
Version 0.010 - 2019-01-02
- Fix several bugs related to multi-line headers
- Also allow 'input' to be a Spreadsheet::ParseExcel::Workbook
- Auto-detection support for ::Decoder::HTML companion module
Version 0.008 - 2018-11-28
- 'input' attribute may now be a Spreadsheet::ParseExcel::Worksheet
- When specifying 'decoder' attribute as an arrayref or hashref,
the CLASS argument is now optional, allowing auto-detection while
still supplying extre optional attributes for the decoder.
- Wrokaround for Libre Office row-max bug
- New Decoder::XLSX attribute 'xls_formatter', useful for casting
local datetimes to a known time zone.
- Prevent loading Text::CSV_XS if its version is too old.
Version 0.007 - 2018-03-15
- Fix various bugs in detect_input_format relevant to CSV files
- Enhanced debug-level logging during the table search algorighm
Version 0.006 - 2018-03-08
- Auto-detect CSV Unicode format by looking for BOM, unless handle
already has an IO layer to specify encoding.
- Improved logging, and logging API. 'log' attribute is no longer public
on Decoder objects.
Version 0.005 - 2017-11-26
- Remove 'filters' feature since it adds overhead and not much value
- Fix bug when creating multiple parallel record iterators
- Sanitize data headers written in logging messages
Version 0.004 - 2017-11-26
- Re-add Text::CSV as a hard dependency since it's small and I need a recent
version for all the tests to pass.
Version 0.003 - 2017-11-25
- Remove hard dependencies on CSV and Excel parsers
- Use new "Mock" decoder for format-independent test cases
- Fix handling of $TableReader->log to match API description
- Fix bugs to be compatible back to 5.8.9
Version 0.002 - 2017-11-24
- Fixed 'filters' feature
- Iterators of decoders are now created on each call, rather than cached
- Many documentation improvements
Version 0.001 - 2017-11-24
- Initial public version
LICENSE 100644 001750 001750 46307 15234670244 17404 0 ustar 00silverdirk silverdirk 000000 000000 Data-TableReader-0.022 This software is copyright (c) 2026 by Michael Conrad.
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.
Terms of the Perl programming language system itself
a) the GNU General Public License as published by the Free
Software Foundation; either version 1, or (at your option) any
later version, or
b) the "Artistic License"
--- The GNU General Public License, Version 1, February 1989 ---
This software is Copyright (c) 2026 by Michael Conrad.
This is free software, licensed under:
The GNU General Public License, Version 1, February 1989
GNU GENERAL PUBLIC LICENSE
Version 1, February 1989
Copyright (C) 1989 Free Software Foundation, Inc.
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The license agreements of most software companies try to keep users
at the mercy of those companies. By contrast, our General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. The
General Public License applies to the Free Software Foundation's
software and to any other program whose authors commit to using it.
You can use it for your programs, too.
When we speak of free software, we are referring to freedom, not
price. Specifically, the General Public License is designed to make
sure that you have the freedom to give away or sell copies of free
software, that you receive source code or can get it if you want it,
that you can change the software or use pieces of it in new free
programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of a such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must tell them their rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any program or other work which
contains a notice placed by the copyright holder saying it may be
distributed under the terms of this General Public License. The
"Program", below, refers to any such program or work, and a "work based
on the Program" means either the Program or any work containing the
Program or a portion of it, either verbatim or with modifications. Each
licensee is addressed as "you".
1. You may copy and distribute verbatim copies of the Program's source
code as you receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice and
disclaimer of warranty; keep intact all the notices that refer to this
General Public License and to the absence of any warranty; and give any
other recipients of the Program a copy of this General Public License
along with the Program. You may charge a fee for the physical act of
transferring a copy.
2. You may modify your copy or copies of the Program or any portion of
it, and copy and distribute such modifications under the terms of Paragraph
1 above, provided that you also do the following:
a) cause the modified files to carry prominent notices stating that
you changed the files and the date of any change; and
b) cause the whole of any work that you distribute or publish, that
in whole or in part contains the Program or any part thereof, either
with or without modifications, to be licensed at no charge to all
third parties under the terms of this General Public License (except
that you may choose to grant warranty protection to some or all
third parties, at your option).
c) If the modified program normally reads commands interactively when
run, you must cause it, when started running for such interactive use
in the simplest and most usual way, to print or display an
announcement including an appropriate copyright notice and a notice
that there is no warranty (or else, saying that you provide a
warranty) and that users may redistribute the program under these
conditions, and telling the user how to view a copy of this General
Public License.
d) You may charge a fee for the physical act of transferring a
copy, and you may at your option offer warranty protection in
exchange for a fee.
Mere aggregation of another independent work with the Program (or its
derivative) on a volume of a storage or distribution medium does not bring
the other work under the scope of these terms.
3. You may copy and distribute the Program (or a portion or derivative of
it, under Paragraph 2) in object code or executable form under the terms of
Paragraphs 1 and 2 above provided that you also do one of the following:
a) accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of
Paragraphs 1 and 2 above; or,
b) accompany it with a written offer, valid for at least three
years, to give any third party free (except for a nominal charge
for the cost of distribution) a complete machine-readable copy of the
corresponding source code, to be distributed under the terms of
Paragraphs 1 and 2 above; or,
c) accompany it with the information you received as to where the
corresponding source code may be obtained. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form alone.)
Source code for a work means the preferred form of the work for making
modifications to it. For an executable file, complete source code means
all the source code for all modules it contains; but, as a special
exception, it need not include source code for modules which are standard
libraries that accompany the operating system on which the executable
file runs, or for standard header files or definitions files that
accompany that operating system.
4. You may not copy, modify, sublicense, distribute or transfer the
Program except as expressly provided under this General Public License.
Any attempt otherwise to copy, modify, sublicense, distribute or transfer
the Program is void, and will automatically terminate your rights to use
the Program under this License. However, parties who have received
copies, or rights to use copies, from you under this General Public
License will not have their licenses terminated so long as such parties
remain in full compliance.
5. By copying, distributing or modifying the Program (or any work based
on the Program) you indicate your acceptance of this license to do so,
and all its terms and conditions.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the original
licensor to copy, distribute or modify the Program subject to these
terms and conditions. You may not impose any further restrictions on the
recipients' exercise of the rights granted herein.
7. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of the license which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
the license, you may choose any version ever published by the Free Software
Foundation.
8. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
Appendix: How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to humanity, the best way to achieve this is to make it
free software which everyone can redistribute and change under these
terms.
To do so, attach the following notices to the program. It is safest to
attach them to the start of each source file to most effectively convey
the exclusion of warranty; and each file should have at least the
"copyright" line and a pointer to where the full notice is found.
Copyright (C) 19yy
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 1, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, see .
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19xx name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the
appropriate parts of the General Public License. Of course, the
commands you use may be called something other than `show w' and `show
c'; they could even be mouse-clicks or menu items--whatever suits your
program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the
program `Gnomovision' (a program to direct compilers to make passes
at assemblers) written by James Hacker.
, 1 April 1989
Moe Ghoul, President of Vice
That's all there is to it!
--- The Perl Artistic License 1.0 ---
This software is Copyright (c) 2026 by Michael Conrad.
This is free software, licensed under:
The Perl Artistic License 1.0
The "Artistic License"
Preamble
The intent of this document is to state the conditions under which a
Package may be copied, such that the Copyright Holder maintains some
semblance of artistic control over the development of the package,
while giving the users of the package the right to use and distribute
the Package in a more-or-less customary fashion, plus the right to make
reasonable modifications.
Definitions:
"Package" refers to the collection of files distributed by the
Copyright Holder, and derivatives of that collection of files
created through textual modification.
"Standard Version" refers to such a Package if it has not been
modified, or has been modified in accordance with the wishes
of the Copyright Holder as specified below.
"Copyright Holder" is whoever is named in the copyright or
copyrights for the package.
"You" is you, if you're thinking about copying or distributing
this Package.
"Reasonable copying fee" is whatever you can justify on the
basis of media cost, duplication charges, time of people involved,
and so on. (You will not be required to justify it to the
Copyright Holder, but only to the computing community at large
as a market that must bear the fee.)
"Freely Available" means that no fee is charged for the item
itself, though there may be fees involved in handling the item.
It also means that recipients of the item may redistribute it
under the same conditions they received it.
1. You may make and give away verbatim copies of the source form of the
Standard Version of this Package without restriction, provided that you
duplicate all of the original copyright notices and associated disclaimers.
2. You may apply bug fixes, portability fixes and other modifications
derived from the Public Domain or from the Copyright Holder. A Package
modified in such a way shall still be considered the Standard Version.
3. You may otherwise modify your copy of this Package in any way, provided
that you insert a prominent notice in each changed file stating how and
when you changed that file, and provided that you do at least ONE of the
following:
a) place your modifications in the Public Domain or otherwise make them
Freely Available, such as by posting said modifications to Usenet or
an equivalent medium, or placing the modifications on a major archive
site such as uunet.uu.net, or by allowing the Copyright Holder to include
your modifications in the Standard Version of the Package.
b) use the modified Package only within your corporation or organization.
c) rename any non-standard executables so the names do not conflict
with standard executables, which must also be provided, and provide
a separate manual page for each non-standard executable that clearly
documents how it differs from the Standard Version.
d) make other distribution arrangements with the Copyright Holder.
4. You may distribute the programs of this Package in object code or
executable form, provided that you do at least ONE of the following:
a) distribute a Standard Version of the executables and library files,
together with instructions (in the manual page or equivalent) on where
to get the Standard Version.
b) accompany the distribution with the machine-readable source of
the Package with your modifications.
c) give non-standard executables non-standard names, and clearly
document the differences in manual pages (or equivalent), together
with instructions on where to get the Standard Version.
d) make other distribution arrangements with the Copyright Holder.
5. You may charge a reasonable copying fee for any distribution of this
Package. You may charge any fee you choose for support of this
Package. You may not charge a fee for this Package itself. However,
you may distribute this Package in aggregate with other (possibly
commercial) programs as part of a larger (possibly commercial) software
distribution provided that you do not advertise this Package as a
product of your own. You may embed this Package's interpreter within
an executable of yours (by linking); this shall be construed as a mere
form of aggregation, provided that the complete Standard Version of the
interpreter is so embedded.
6. The scripts and library files supplied as input to or produced as
output from the programs of this Package do not automatically fall
under the copyright of this Package, but belong to whoever generated
them, and may be sold commercially, and may be aggregated with this
Package. If such scripts or library files are aggregated with this
Package via the so-called "undump" or "unexec" methods of producing a
binary executable image, then distribution of such an image shall
neither be construed as a distribution of this Package nor shall it
fall under the restrictions of Paragraphs 3 and 4, provided that you do
not represent such an executable image as a Standard Version of this
Package.
7. C subroutines (or comparably compiled subroutines in other
languages) supplied by you and linked into this Package in order to
emulate subroutines and variables of the language defined by this
Package shall not be considered part of this Package, but are the
equivalent of input as in Paragraph 6, provided these subroutines do
not change the language in any way that would cause it to fail the
regression tests for the language.
8. Aggregation of this Package with a commercial distribution is always
permitted provided that the use of this Package is embedded; that is,
when no overt attempt is made to make this Package's interfaces visible
to the end user of the commercial distribution. Such use shall not be
construed as a distribution of this Package.
9. The name of the Copyright Holder may not be used to endorse or promote
products derived from this software without specific prior written permission.
10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
The End
dist.ini 100644 001750 001750 2775 15234670244 20024 0 ustar 00silverdirk silverdirk 000000 000000 Data-TableReader-0.022 name = Data-TableReader
abstract = Locate and read records from human-edited data tables (Excel, CSV)
author = Michael Conrad
license = Perl_5
copyright_holder = Michael Conrad
[MetaResources]
homepage = https://github.com/nrdvana/perl-Data-TableReader
bugtracker.web = https://github.com/nrdvana/perl-Data-TableReader/issues
repository.web = https://github.com/nrdvana/perl-Data-TableReader
repository.url = https://github.com/nrdvana/perl-Data-TableReader.git
repository.type = git
[@Git]
[Git::Contributors]
[Git::GatherDir]
exclude_match = ^t/tmp
exclude_match = ^Decoder-.*
include_untracked = 0
[Encoding]
encoding = bytes
match = ^t/data/
[Git::NextVersion]
[OurPkgVersion]
[PodWeaver]
[PodSyntaxTests]
[Test::Pod::Coverage::Configurable]
also_private=BUILD
[MakeMaker]
[License]
[Readme]
; authordep Pod::Weaver::Section::Contributors
; authordep Pod::Elemental::Transformer::List
[AutoPrereqs]
skip = MRO::Compat
skip = Types::Standard
[Prereqs]
Text::CSV = 1.95
[Prereqs / RuntimeRecommends]
Text::CSV_XS = 1.06
Spreadsheet::ParseExcel = 0
Spreadsheet::ParseXLSX = 0
Data::TableReader::Decoder::HTML = 0
[Prereqs / TestRequires]
Log::Any::Adapter::TAP = 0
[Prereqs / TestRecommends]
Spreadsheet::ParseXLSX = 0
[Prereqs / DevelopRequires]
Pod::Weaver::Section::Contributors = 0
Pod::Elemental::Transformer::List = 0
[DynamicPrereqs]
-condition = "$]" < '5.010'
-body = requires('MRO::Compat');
[Manifest]
[MetaYAML]
[MetaJSON]
[UploadToCPAN]
MANIFEST 100644 001750 001750 1745 15234670244 17505 0 ustar 00silverdirk silverdirk 000000 000000 Data-TableReader-0.022 # This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.036.
Changes
LICENSE
MANIFEST
META.json
META.yml
Makefile.PL
README
README.md
SciTEDirectory.properties
dist.ini
lib/Data/TableReader.pm
lib/Data/TableReader/Decoder.pm
lib/Data/TableReader/Decoder/CSV.pm
lib/Data/TableReader/Decoder/IdiotCSV.pm
lib/Data/TableReader/Decoder/Mock.pm
lib/Data/TableReader/Decoder/Spreadsheet.pm
lib/Data/TableReader/Decoder/TSV.pm
lib/Data/TableReader/Decoder/XLS.pm
lib/Data/TableReader/Decoder/XLSX.pm
lib/Data/TableReader/Field.pm
lib/Data/TableReader/Iterator.pm
t/01-env-check.t
t/05-field.t
t/09-decoder-mock.t
t/10-decoder-csv.t
t/11-decoder-tsv.t
t/12-decoder-idiot-csv.t
t/15-decoder-xls.t
t/30-detect-input-format.t
t/35-record-iterator.t
t/40-locate-table.t
t/41-user-supplied-colmap.t
t/42-user-overrides-found-header.t
t/50-validation.t
t/51-typetiny-validation.t
t/data/AddressAuxData.xls
t/data/AddressAuxData.xlsx
weaver.ini
xt/author/pod-coverage.t
xt/author/pod-syntax.t
META.yml 100644 001750 001750 2607 15234670244 17623 0 ustar 00silverdirk silverdirk 000000 000000 Data-TableReader-0.022 ---
abstract: 'Locate and read records from human-edited data tables (Excel, CSV)'
author:
- 'Michael Conrad '
build_requires:
File::Spec::Functions: '0'
Log::Any::Adapter: '0'
Log::Any::Adapter::TAP: '0'
Test::More: '0'
configure_requires:
ExtUtils::MakeMaker: '0'
dynamic_config: 1
generated_by: 'Dist::Zilla version 6.036, CPAN::Meta::Converter version 2.150010'
license: perl
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.4.html
version: '1.4'
name: Data-TableReader
recommends:
Data::TableReader::Decoder::HTML: '0'
Spreadsheet::ParseExcel: '0'
Spreadsheet::ParseXLSX: '0'
Text::CSV_XS: '1.06'
requires:
Carp: '0'
Encode: '0'
IO::Handle: '0'
List::Util: '0'
Log::Any: '0'
Module::Runtime: '0'
Moo: '2'
Scalar::Util: '0'
Text::CSV: '1.95'
namespace::clean: '0'
overload: '0'
strict: '0'
warnings: '0'
resources:
bugtracker: https://github.com/nrdvana/perl-Data-TableReader/issues
homepage: https://github.com/nrdvana/perl-Data-TableReader
repository: https://github.com/nrdvana/perl-Data-TableReader.git
version: '0.022'
x_contributors:
- 'Christian Walde '
- 'Étienne Mollier '
- 'Michael Conrad '
x_generated_by_perl: v5.40.0
x_serialization_backend: 'YAML::Tiny version 1.74'
x_spdx_expression: 'Artistic-1.0-Perl OR GPL-1.0-or-later'
README.md 100644 001750 001750 711 15234670244 17603 0 ustar 00silverdirk silverdirk 000000 000000 Data-TableReader-0.022 # Data::TableReader
This perl module helps take un-sanitized tabular data sources and verify that
they match your expected schema, and then iterate the records.
You can install the latest stable release of this module from CPAN:
cpanm Data::TableReader
or build and install this source code with the Dist::Zilla tool:
dzil build
cpanm ./Data-TableReader-$VERSION
The source is found at
http://github.com/nrdvana/perl-Data-TableReader
META.json 100644 001750 001750 5213 15234670244 17767 0 ustar 00silverdirk silverdirk 000000 000000 Data-TableReader-0.022 {
"abstract" : "Locate and read records from human-edited data tables (Excel, CSV)",
"author" : [
"Michael Conrad "
],
"dynamic_config" : 1,
"generated_by" : "Dist::Zilla version 6.036, CPAN::Meta::Converter version 2.150010",
"license" : [
"perl_5"
],
"meta-spec" : {
"url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec",
"version" : 2
},
"name" : "Data-TableReader",
"prereqs" : {
"configure" : {
"requires" : {
"ExtUtils::MakeMaker" : "0"
}
},
"develop" : {
"requires" : {
"Pod::Coverage::TrustPod" : "0",
"Pod::Elemental::Transformer::List" : "0",
"Pod::Weaver::Section::Contributors" : "0",
"Test::More" : "0.88",
"Test::Pod" : "1.41",
"Test::Pod::Coverage" : "1.08"
}
},
"runtime" : {
"recommends" : {
"Data::TableReader::Decoder::HTML" : "0",
"Spreadsheet::ParseExcel" : "0",
"Spreadsheet::ParseXLSX" : "0",
"Text::CSV_XS" : "1.06"
},
"requires" : {
"Carp" : "0",
"Encode" : "0",
"IO::Handle" : "0",
"List::Util" : "0",
"Log::Any" : "0",
"Module::Runtime" : "0",
"Moo" : "2",
"Scalar::Util" : "0",
"Text::CSV" : "1.95",
"namespace::clean" : "0",
"overload" : "0",
"strict" : "0",
"warnings" : "0"
}
},
"test" : {
"recommends" : {
"Spreadsheet::ParseXLSX" : "0"
},
"requires" : {
"File::Spec::Functions" : "0",
"Log::Any::Adapter" : "0",
"Log::Any::Adapter::TAP" : "0",
"Test::More" : "0"
}
}
},
"release_status" : "stable",
"resources" : {
"bugtracker" : {
"web" : "https://github.com/nrdvana/perl-Data-TableReader/issues"
},
"homepage" : "https://github.com/nrdvana/perl-Data-TableReader",
"repository" : {
"type" : "git",
"url" : "https://github.com/nrdvana/perl-Data-TableReader.git",
"web" : "https://github.com/nrdvana/perl-Data-TableReader"
}
},
"version" : "0.022",
"x_contributors" : [
"Christian Walde ",
"\u00c9tienne Mollier ",
"Michael Conrad "
],
"x_generated_by_perl" : "v5.40.0",
"x_serialization_backend" : "Cpanel::JSON::XS version 4.38",
"x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later"
}
weaver.ini 100644 001750 001750 570 15234670244 20321 0 ustar 00silverdirk silverdirk 000000 000000 Data-TableReader-0.022 [@CorePrep]
[-SingleEncoding]
[Name]
[Version]
[Region / prelude]
[Generic / SYNOPSIS]
[Generic / DESCRIPTION]
[Generic / OVERVIEW]
[Collect / ATTRIBUTES]
command = attr
[Collect / METHODS]
command = method
[Collect / FUNCTIONS]
command = func
[Leftovers]
[Region / postlude]
[Generic / Thanks]
[Authors]
[-Transformer]
transformer = List
[Contributors]
[Legal]
Makefile.PL 100644 001750 001750 5375 15234670244 20331 0 ustar 00silverdirk silverdirk 000000 000000 Data-TableReader-0.022 # This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v6.036.
use strict;
use warnings;
use ExtUtils::MakeMaker;
my %WriteMakefileArgs = (
"ABSTRACT" => "Locate and read records from human-edited data tables (Excel, CSV)",
"AUTHOR" => "Michael Conrad ",
"CONFIGURE_REQUIRES" => {
"ExtUtils::MakeMaker" => 0
},
"DISTNAME" => "Data-TableReader",
"LICENSE" => "perl",
"NAME" => "Data::TableReader",
"PREREQ_PM" => {
"Carp" => 0,
"Encode" => 0,
"IO::Handle" => 0,
"List::Util" => 0,
"Log::Any" => 0,
"Module::Runtime" => 0,
"Moo" => 2,
"Scalar::Util" => 0,
"Text::CSV" => "1.95",
"namespace::clean" => 0,
"overload" => 0,
"strict" => 0,
"warnings" => 0
},
"TEST_REQUIRES" => {
"File::Spec::Functions" => 0,
"Log::Any::Adapter" => 0,
"Log::Any::Adapter::TAP" => 0,
"Test::More" => 0
},
"VERSION" => "0.022",
"test" => {
"TESTS" => "t/*.t"
}
);
my %FallbackPrereqs = (
"Carp" => 0,
"Encode" => 0,
"File::Spec::Functions" => 0,
"IO::Handle" => 0,
"List::Util" => 0,
"Log::Any" => 0,
"Log::Any::Adapter" => 0,
"Log::Any::Adapter::TAP" => 0,
"Module::Runtime" => 0,
"Moo" => 2,
"Scalar::Util" => 0,
"Test::More" => 0,
"Text::CSV" => "1.95",
"namespace::clean" => 0,
"overload" => 0,
"strict" => 0,
"warnings" => 0
);
# inserted by Dist::Zilla::Plugin::DynamicPrereqs 0.040
if ("$]" < '5.010') {
requires('MRO::Compat');
}
unless ( eval { ExtUtils::MakeMaker->VERSION(6.63_03) } ) {
delete $WriteMakefileArgs{TEST_REQUIRES};
delete $WriteMakefileArgs{BUILD_REQUIRES};
$WriteMakefileArgs{PREREQ_PM} = \%FallbackPrereqs;
}
delete $WriteMakefileArgs{CONFIGURE_REQUIRES}
unless eval { ExtUtils::MakeMaker->VERSION(6.52) };
WriteMakefile(%WriteMakefileArgs);
# inserted by Dist::Zilla::Plugin::DynamicPrereqs 0.040
sub _add_prereq {
my ($mm_key, $module, $version_or_range) = @_;
$version_or_range ||= 0;
warn "$module already exists in $mm_key (at version $WriteMakefileArgs{$mm_key}{$module}) -- need to do a sane metamerge!"
if exists $WriteMakefileArgs{$mm_key}{$module}
and $WriteMakefileArgs{$mm_key}{$module} ne '0'
and $WriteMakefileArgs{$mm_key}{$module} ne $version_or_range;
warn "$module already exists in FallbackPrereqs (at version $FallbackPrereqs{$module}) -- need to do a sane metamerge!"
if exists $FallbackPrereqs{$module} and $FallbackPrereqs{$module} ne '0'
and $FallbackPrereqs{$module} ne $version_or_range;
$WriteMakefileArgs{$mm_key}{$module} = $FallbackPrereqs{$module} = $version_or_range;
return;
}
sub requires { goto &runtime_requires }
sub runtime_requires {
my ($module, $version_or_range) = @_;
_add_prereq(PREREQ_PM => $module, $version_or_range);
}
t 000755 001750 001750 0 15234670244 16450 5 ustar 00silverdirk silverdirk 000000 000000 Data-TableReader-0.022 05-field.t 100644 001750 001750 4525 15234670244 20310 0 ustar 00silverdirk silverdirk 000000 000000 Data-TableReader-0.022/t #! /usr/bin/env perl
use strict;
use warnings;
use Test::More;
use_ok( 'Data::TableReader::Field' ) or BAIL_OUT;
subtest header_regex => sub {
my @tests= ({
name => 'name', header => undef,
match => [ 'name', ' nAMe', '^%name&*^%^' ],
nomatch => [ 'na me', 'names', 'surname', 'first name' ],
},{
name => 'first_name', header => undef,
match => [ 'first name', 'FirstName', ' First_Name', 'First.Name' ],
nomatch => [ 'first_nam', 'first.*', 'name', 'first name 0' ],
},{
name => 'first_name', header => 'first_name',
match => [ 'first_name', ' first_name', 'first_name#"$:^' ],
nomatch => [ 'first name', 'first.name', 'first _name', 'FirstName' ],
},{
name => 'zip5',
match => [ 'zip5', 'zip 5', 'zip_5', 'ZIP-5' ],
nomatch => [ 'zip' ],
},{
name => 'ZipCode',
match => [ 'ZipCode', 'zip code', 'zip.code', 'ZIP CODE', '--ZIP CODE--' ],
nomatch => [ 'ZipCode(5)' ],
},{
name => 'ZipCode', header => "Zip\nCode",
match => ["Zip\nCode", "zip \n code"],
nomatch => [ 'zipcode' ],
});
plan tests => scalar @tests;
for my $t (@tests) {
subtest "name=$t->{name} header=".($t->{header}||'') => sub {
plan tests => 1 + @{$t->{match}} + @{$t->{nomatch}};
my $field= new_ok( 'Data::TableReader::Field',
[ name => $t->{name}, header => $t->{header} ], 'field' );
like( $_, $field->header_regex, "match $_" ) for @{ $t->{match} };
unlike( $_, $field->header_regex, "nomatch $_" ) for @{ $t->{nomatch} };
};
}
};
subtest trim => sub {
my @tests= ({
name => 'true', trim => 1,
input => [ 'x', ' x', 'x ', ' x ', ' ' ],
expected => [ 'x', 'x', 'x', 'x', '' ],
},{
name => 'regex', trim => qr/^\s*N\/A\s*$|^\s*NULL\s*$|^\s+|\s+$/i,
input => [ 'x', ' x', 'x ', ' x ', 'N/A', ' N/A ', ' Null ' ],
expected => [ 'x', 'x', 'x', 'x', '', '', '' ],
},{
name => 'coderef', trim => sub { s/\s+/_/g; },
input => [ 'x x', ' x' ],
expected => [ 'x_x', '_x' ],
});
plan tests => scalar @tests;
for my $t (@tests) {
subtest "name=$t->{name}" => sub {
plan tests => 1 + @{$t->{input}};
my $field= new_ok( 'Data::TableReader::Field',
[ name => $t->{name}, trim => $t->{trim} ], 'field' );
for (0.. $#{$t->{input}}) {
my ($in, $expected)= ( $t->{input}[$_], $t->{expected}[$_] );
$field->trim_coderef->() for my $out= $in;
is( $out, $expected, $in );
}
};
}
};
done_testing;
01-env-check.t 100644 001750 001750 615 15234670244 21040 0 ustar 00silverdirk silverdirk 000000 000000 Data-TableReader-0.022/t #! /usr/bin/env perl
use strict;
use warnings;
use Test::More tests => 1;
diag "Checking optional modules";
for (qw(
Text::CSV
Text::CSV_XS
Archive::Zip
Spreadsheet::XLSX
Spreadsheet::ParseXLSX
Spreadsheet::ParseExcel
Type::Tiny
Types::Standard
)) {
if (eval "require $_") {
diag "Have $_ ".$_->VERSION;
} else {
diag "No $_";
}
}
pass('This is just for CPAN testers reports');
50-validation.t 100644 001750 001750 7356 15234670244 21364 0 ustar 00silverdirk silverdirk 000000 000000 Data-TableReader-0.022/t #! /usr/bin/env perl
use strict;
use warnings;
use Test::More;
use File::Spec::Functions 'catfile';
use Log::Any '$log';
use Log::Any::Adapter 'TAP', filter => 'none';
use_ok( 'Data::TableReader' ) or BAIL_OUT;
sub is_alpha { defined $_[0] and $_[0] =~ /^[a-z]+$/? undef : 'not alpha' }
sub is_num { defined $_[0] and $_[0] =~ /^[0-9]+$/? undef : 'not numeric' }
# Find fields in the exact order they are present in the file
subtest validation_die => sub {
my @log;
my $tr= new_ok( 'Data::TableReader', [
input => [ ['X'], ['abc'], ['123'], ['def'] ],
fields => [{ name => 'X', type => \&is_alpha }],
log => \@log
], 'TableReader' );
my $i= $tr->iterator;
is_deeply( eval { $i->() }, { X => 'abc' }, 'valid row' );
like( do { local $@; eval { $i->() }; my $e= $@ }, qr/not alpha/, 'invalid row' );
is_deeply( eval { $i->() }, { X => 'def' }, 'valid row' );
is( $i->(), undef, 'eof' );
};
subtest validation_next => sub {
open(my $csv, '<', \"X\n1\n2\n\n15\nX\nY\nZ\n16\n") or die;
my $tr= new_ok( 'Data::TableReader', [
input => [ ['X'], ['1'], ['2'], [''], ['15'], ['X'], ['Y'], ['Z'], ['16'] ],
fields => [{ name => 'X', type => \&is_num }],
on_validation_fail => 'next',
log => \my @log
], 'TableReader' );
is_deeply( $tr->iterator->all, [ { X => 1 }, { X => 2 }, { X => 15 }, { X => 16 } ], 'only numeric values' )
or note explain \@log;
};
subtest validation_use => sub {
my @log;
my $tr= new_ok( 'Data::TableReader', [
input => [ ['X'], ['1'], ['2'], ['x'], ['15'] ],
fields => [{ name => 'X', type => \&is_num }],
on_validation_fail => 'use',
log => \@log
], 'TableReader' );
is_deeply( $tr->iterator->all, [ { X => 1 }, { X => 2 }, { X => 'x' }, { X => 15 } ], 'keep all values' );
is( scalar(grep { $_->[0] eq 'warn' } @log), 1, 'one warning' );
like( $log[0][1], qr/not numeric/, 'warn about non-numeric' );
};
subtest validation_custom => sub {
my @log;
my $tr= new_ok( 'Data::TableReader', [
input => [ ['X'], ['1'], ['2'], ['x'], ['15'] ],
fields => [{ name => 'X', type => \&is_num }],
on_validation_fail => sub {
my ($reader, $failures, $values, $context)= @_;
for (@$failures) {
my ($field, $value_index, $message)= @$_;
if ($field->name eq 'X') {
$values->[$value_index]= 0;
$_= undef;
}
}
@$failures= grep defined, @$failures;
return 'use';
},
log => \@log
], 'TableReader' );
is_deeply( $tr->iterator->all, [ { X => 1 }, { X => 2 }, { X => 0 }, { X => 15 } ], 'keep munged value' );
is_deeply( \@log, [], 'no warnings' ) or note explain @log;
};
subtest validation_new_api => sub {
my @log;
my $tr= new_ok( 'Data::TableReader', [
input => [ ['X', 'X', 'Y'], [1,1,1], ['2','3'], ['x',5], ['15'] ],
fields => [
{ name => 'X', type => \&is_num, array => 1 },
{ name => 'y', type => \&is_num }
],
on_validation_error => sub {
my ($reader, $failures, $record, $data_iter)= @_;
for (@$failures) {
my ($field, $value_ref, $message, $path)= @$_;
if ($field->name eq 'X') {
$$value_ref= 0;
$_= undef;
} elsif ($field->name eq 'y') {
$$value_ref= -1;
$_= undef;
}
}
@$failures= grep defined, @$failures;
return 'use';
},
log => \@log
], 'TableReader' );
is_deeply( [ map +($_? $_->name : undef), @{$tr->col_map} ], [ 'X', 'X', 'y' ], 'col_map' );
is_deeply( $tr->iterator->all, [
{ X => [1,1], y => 1 },
{ X => [2,3], y => -1 },
{ X => [0,5], y => -1 },
{ X => [15,0], y => -1 }
], 'keep munged value' );
is_deeply( \@log, [], 'no warnings' ) or note explain @log;
};
done_testing;
sub open_data {
my $name= shift;
my $t_dir= __FILE__;
$t_dir =~ s,[^\/]+$,,;
$name= catfile($t_dir, 'data', $name);
open(my $fh, "<:raw", $name) or die "open($name): $!";
return $fh;
}
10-decoder-csv.t 100644 001750 001750 11501 15234670244 21427 0 ustar 00silverdirk silverdirk 000000 000000 Data-TableReader-0.022/t #! /usr/bin/env perl
use strict;
use warnings;
use Test::More;
use Log::Any '$log';
use Log::Any::Adapter 'TAP';
use Data::TableReader::Decoder::CSV;
my $csvmod;
plan skip_all => 'Need a CSV parser for this test'
unless eval { $csvmod= Data::TableReader::Decoder::CSV->default_csv_module };
note "CSV decoder is ".$csvmod." version ".$csvmod->VERSION;
my $log_fn= sub { $log->can($_[0])->($log, $_[1]) };
sub test_basic {
my $input= ascii();
open my $input_fh, '<', \$input or die;
my $d= new_ok( 'Data::TableReader::Decoder::CSV',
[ file_name => '', file_handle => $input_fh, _log => $log_fn ],
'CSV decoder' );
ok( my $iter= $d->iterator, 'got iterator' );
is_deeply( $iter->(), [ 'a', 'b', 'c', 'd' ], 'first row' );
is( $iter->row, 1, 'row=1' );
is( $iter->dataset_idx, 0, 'dataset_idx=0' );
is_deeply( $iter->(), [ '1', '2', '3', '4' ], 'second row' );
is( $iter->row, 2, 'row=2' );
is_deeply( $iter->(), undef, 'no third row' );
is( $iter->row, 2, 'row=2' );
is( $iter->dataset_idx, 0, 'dataset_idx=0' );
ok( $iter->seek(0), 'rewind' );
is( $iter->row, 0, 'row=0' );
is_deeply( $iter->(), [ 'a', 'b', 'c', 'd' ], 'first row again' );
is( $iter->row, 1, 'row=1' );
is_deeply( $iter->([2,1]), [ '3', '2' ], 'slice from second row' );
ok( !$iter->next_dataset, 'no next dataset' );
is( $iter->dataset_idx, 0, 'dataset_idx=0' );
}
sub test_multi_iterator {
my $input= ascii();
open my $input_fh, '<', \$input or die;
my $d= new_ok( 'Data::TableReader::Decoder::CSV',
[ file_name => '', file_handle => $input_fh, _log => $log_fn ],
'CSV decoder' );
ok( my $iter= $d->iterator, 'create first iterator' );
# This might be supported in the future, but for now ensure it dies
like( do { local $@; eval { $d->iterator }; my $e= $@ }, qr/multiple iterator/i, 'error for multiple iterators' );
undef $iter; # release old iterator, freeing up the file handle to create a new one
ok( $iter= $d->iterator, 'new iterator' );
is_deeply( $iter->(), [ 'a', 'b', 'c', 'd' ], 'first row again' );
}
sub test_utf_bom {
for my $input_fn (qw( utf8_bom utf16_le_bom utf16_be_bom utf8_nobom deceptive_utf8_nobom )) {
subtest "seekable $input_fn" => sub {
my $input= main->$input_fn;
open my $input_fh, '<', \$input or die;
my $d= new_ok( 'Data::TableReader::Decoder::CSV',
[ file_name => '', file_handle => $input_fh, _log => $log_fn ],
"CSV decoder for $input_fn" );
ok( my $iter= $d->iterator, 'got iterator' );
like( $iter->()[0], qr/^\x{FFFD}?test$/, 'first row' );
is_deeply( $iter->(), [ "\x{8A66}\x{3057}", 1, 2, 3 ], 'second row' );
is_deeply( $iter->(), [ "\x{27000}" ], 'third row' );
is_deeply( $iter->(), undef, 'no fourth row' );
ok( $iter->seek(0), 'rewind' );
# workaround for a perl bug! the input string gets corrupted
substr($input,0,8)= substr(main->$input_fn,0,8);
like( $iter->()[0], qr/^\x{FFFD}?test$/, 'first row' );
is_deeply( $iter->([0,3]), [ "\x{8A66}\x{3057}", 3 ], 'slice from second row' );
ok( !$iter->next_dataset, 'no next dataset' );
};
subtest "nonseekable $input_fn" => sub {
my $input= main->$input_fn;
pipe(my ($input_fh, $out_fh)) or die "pipe: $!";
print $out_fh $input or die "print(pipe_out): $!";
close $out_fh or die "close: $!";
my $d= new_ok( 'Data::TableReader::Decoder::CSV',
[ file_name => '', file_handle => $input_fh, _log => $log_fn ],
"CSV decoder for $input_fn" );
if ($input_fn =~ /deceptive/) {
# Some inputs on non-seekable file handles will result in this exception.
# This is expected.
like( do { local $@; eval { $d->iterator }; my $e= $@ }, qr/seek/, 'can\'t seek exception' );
} else {
ok( my $iter= $d->iterator, 'got iterator' );
like( $iter->()[0], qr/^\x{FFFD}?test$/, 'first row' );
is_deeply( $iter->(), [ "\x{8A66}\x{3057}", 1, 2, 3 ], 'second row' );
is_deeply( $iter->(), [ "\x{27000}" ], 'third row' );
is_deeply( $iter->(), undef, 'no fourth row' );
ok( !$iter->next_dataset, 'no next dataset' );
}
};
}
}
subtest basic => \&test_basic;
subtest multi_iter => \&test_multi_iterator;
subtest utf_bom => \&test_utf_bom;
done_testing;
sub ascii {
return <