Data::TableReader::Decoder::CSV - Access rows of a comma-delimited text file


version 0.011


This decoder wraps an instance of either Text::CSV or Text::CSV_XS. You may pass your own options via the "parser" attribute, which will override the defaults of this module on a per-field basis.

This module defaults to:

  parser => {
    binary => 1,
    allow_loose_quotes => 1,
    auto_diag => 2,

This module makes an attempt at automatic unicode support:

  • If the stream has a PerlIO encoding() on it, no additional decoding is done.

  • If the stream has a BOM (byte-order mark) for UTF-8 or UTF-16, it adds that encoding with binmode.

  • Else, it lets the parser decide. The default Text::CSV parser will automatically upgrade UTF-8 sequences that it finds. (and, you can't disable this without also disabling unicode received from IO layers, which seems like a bug...)

Because auto-detection might need to read multiple bytes, it is possible that for non-seekable streams (like pipes, stdin, etc) this may result in an exception. Only un-seekable streams beginning with "\xEF", "\xFE", or "\xFF" will have this problem. You can solve this by supplying an encoding layer on the file handle (avoiding detection), setting "autodetect_encoding" to false, buffering the entire input in a scalar and creating a file handle from that (making it seekable), or using a file handle that supports "ungets" like FileHandle::Unget.



An instance of Text::CSV or Text::CSV_XS or compatible, or arguments to pass to the constructor. Constructor arguments are passed to CSV_XS if it is installed, else CSV.


Whether to look for a byte-order mark on the input.


If autodetection is enabled, this will first check for a byte-order mark on the input. Else, or afterward, it will return whatever encoding PerlIO layer is configured on the file handle. Setting this attribute will change the PerlIO layer on the file handle, possibly skipping detection.


  my $iterator= $decoder->iterator;

Return an iterator which returns each row of the table as an arrayref.


Michael Conrad <>


This software is copyright (c) 2019 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.