Data::TableReader::Decoder::IdiotCSV(3pm)

Data::TableReader::Decoder::IdiotCSV3pm

Access rows of a badly formatted comma-delimited text file

Version

version 0.021

Overview

This decoder is like ::Decoder::CSV, but can additionally parse the garbage resulting from those special people who write "CSV Export" code that looks like

  print join(",", map qq{"$_"}, @record)."\n";

(or rather, the equivalent code in Visual Basic or PHP which is what they're probably using) regardless of their data containing quote characters or newlines, resulting in garbage like:

  "First Name","Last Name","email"
  "Joseph "Joe","Smith",""Smith, Joe" <[email protected]>"

This can actually be processed by (recent versions of) the Text::CSV module with the following configuration:

  {
    binary => 1,
    allow_loose_quotes => 1,
    allow_whitespace => 1,
    escape_char => undef,
  }

And so this module is simply a subclass of Data::TableReader::Decoder::CSV which provides those defaults to the parser.

How does the parsing work though? Well, some guesswork and patterns. It's not super reliable, and you should always complain loudly to whoever generated that data, unless they're a much larger company than you and would never listen, or went out of business a while back, in which case you can justify using this module in production.

Releases

4 releases since Debian 10 (Buster); the text changed 3 times.

  1. 10
  2. 11
  3. 12
  4. 13

Author

Michael Conrad <[email protected]>

From libdata-tablereader-perl 0.021-1 in Debian 13 (Trixie). Parsed by carta from the page's man source.