Data::...er::CSV(3pm)
β¨ NAME β¨
Data::TableReader::Decoder::CSV β bestie, this is the thing that lets you read rows out of a comma-delimited text file π it's a decoder, part of the Data::TableReader fam, and it's giving "yes i will hand you the CSV data, one row at a time, no drama"
πΈ VERSION πΈ
version 0.021 β she's a specific girlie, okay? remember her number π
π¦ DESCRIPTION π¦
okay so real talk: this decoder is literally just a glow-up wrapper around an instance of either Text::CSV or Text::CSV_XS. you can bring your own options via the parser attribute, and they'll override this module's defaults on a per-field basis β so your settings win where you set them, periodt β¨
this module defaults to:
parser => {
binary => 1,
allow_loose_quotes => 1,
auto_diag => 2,
}
like, those are the factory settings, the no-thoughts-just-vibes config π
she also makes an attempt at automatic unicode support, which is so main character of her:
- if the stream already has a PerlIO
encoding()on it, no additional decoding is done. she's like "you handled it, i respect that" π«Ά - if the stream has a BOM (byte-order mark) for UTF-8 or UTF-16, she adds that encoding with
binmode. - else, she lets the parser decide. the default
Text::CSVparser 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... π)
β οΈ okay so here's the tea: 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, so it's a very specific vibe of cursed.
you can solve this by:
- supplying an encoding layer on the file handle (avoiding detection),
- setting
autodetect_encodingto 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
ungetslikeFileHandle::Unget.
slay, four whole options, pick your fighter π
π ATTRIBUTES π
π parser
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. so like, she checks who's home and calls accordingly π₯
π autodetect_encoding
whether to look for a byte-order mark on the input. that's it, that's the whole vibe check πΈ
π encoding
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. so she can tell you what's up, and she can also change what's up, which is lowkey powerful π
π iterator
my $iterator= $decoder->iterator;
return an iterator which returns each row of the table as an arrayref. one row at a time, bestie, like a lil conveyor belt of data π
π§ AUTHOR π§
Michael Conrad <mike@nrdvana.net> β thank you king, we appreciate you π«Ά
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2024 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. so like, go forth, remix, redistribute, it's free fr fr β
and that's the whole page, bestie!! π she's Data::TableReader::Decoder::CSV, version 0.021, documented by the perl that lives at v5.38.2, dated 2024-06-21 β no cap, that's the timestamp, and you're all caught up π
β¨
π¦ where this page comes from
- debian trixie: libdata-tablereader-perl 0.021-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libdata-tablereader-perl 0.021-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libdata-tablereader-perl 0.021-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms