PGObje...eudoCSV(3pm)
πΈ PGObject::Util::PseudoCSV πΈ
okay bestie, welcome to the User Contributed Perl Documentation for PGObject::Util::PseudoCSV(3pm) β it's giving "PostgreSQL text formats but make it parseable" and honestly? we're obsessed. π
β¨ NAME β¨
PGObject::Util::PseudoCSV - Tuple/Array parsing and serialization for PGObject
π VERSION π
Version 2
π SYNOPSIS π
So this whole thing is a parser and a constructor for PostgreSQL's text representations of tuples and arrays. Two jobs, one queen. π
To parse, for a tuple we'd typically do:
my @list = pseudocsv_parse($text_representation);
Then we can arrange the hash like this:
my $hashref = pseudocsv_to_hash(\@list, \@col_list);
And we can combine those two moves into one iconic little moment:
my $hashref = pseudocsv_to_hash(
pseudocsv_parse($text_representation),
\@col_list
);
π¦ DESCRIPTION π¦
PostgreSQL can represent tuples and arrays in a text format that is almost like CSV. Almost. π And that "almost" is exactly the problem β this format has a whole bunch of gotchas that render existing CSV-parsers useless. So this module steps in and provides basic parsing functions to other programs for db interface purposes. With this module you can both parse pseudocsv representations of tuples and arrays, and you can create them from a list. Periodt. β¨
The APIs here assume you send one (and only one) pseudo-csv record to the API at once. These may be nested, so a single tuple can contain arrays of tuples which can contain arrays of tuples ad infinitum β but the parsing only goes one layer deep tuple-wise, so that handling classes have an opportunity to re-parse with appropriate type information. Naturally this has performance implications, so depth in SQL structures passed should be reasonably limited. > lowkey don't go feral with the nesting, bestie π
As of 2.0, we no longer automatically call deserialization functions from the parser itself. At his point the calling classes MUST call the deserializer themselves β but this is far easier since this has been moved to a separate service in PGObject 2.0. This avoids an unnecessary dependency on PGObject and ensures that the module is more geneally useful. π«Ά
π EXPORT π
pseudocsv_to_hashpseudocsv_parseto_pseudocsv
π SUBROUTINES/METHODS π
pseudocsv_parse
This does a one-level deep parse of the pseudo-csv, with additional levels in arrays. When a tuple is encountered it is instantiated as its type, but a subarray is parsed for more entities. π§
Only one pseudocsv record can be passed in at once, but embedded newlines are properly handled. no cap. π
pcsv2hash($literal_string, @cols);
Returns a hash from a tuple literal or array literal.
hash2pcsv($hashref, @cols)
Takes an ordered list of columns and a hashref and returns a tuple literal.
pseudocsv_tohash($coldata, $colnames) DEPRECATED
Takes an arrayref of column data and an arrayref of column names and returns a hash. This is mostly a helper function designed to help with tuple types.
β οΈ This interface is deprecated and will go away in 2.0. Use pcsv2hash instead.
to_pseudocsv($datalist, $is_tuple)
Takes a list of data and an is_tuple argument and creates a pseudocsv.
π¨ Note: this does not check for array sanity. If you are not careful you can get arrays returned which are not valid SQL arrays. Remember that SQL arrays have every item being the same size, and all SQL arrays are are regular in size (so all 1 and 2d arrays follow the same form as mathematical matrices).
π AUTHOR π
Chris Travers, "<chris.travers at gmail.com>"
π BUGS π
Please report any bugs or feature requests to "bug-pgobject-util-pseudocsv at rt.cpan.org", or through the web interface at <http://rt.cpan.org/NoAuth/ReportBug.html?Queue=PGObject-Util-PseudoCSV>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. β¨ (yes bestie, you get receipts. we love accountability.)
π SUPPORT π
You can find documentation for this module with the perldoc command.
perldoc PGObject::Util::PseudoCSV
You can also look for information at:
- RT: CPAN's request tracker (report bugs here)
<http://rt.cpan.org/NoAuth/Bugs.html?Dist=PGObject-Util-PseudoCSV>
- AnnoCPAN: Annotated CPAN documentation
<http://annocpan.org/dist/PGObject-Util-PseudoCSV>
- CPAN Ratings
<http://cpanratings.perl.org/d/PGObject-Util-PseudoCSV>
- Search CPAN
<http://search.cpan.org/dist/PGObject-Util-PseudoCSV/>
πΈ ACKNOWLEDGEMENTS πΈ
(nothing here, bestie β this section is serving empty-plate energy π½οΈβ¨ but we're keeping it because the original kept it, and we respect the canon.)
π LICENSE AND COPYRIGHT π
Copyright 2014-2017 Chris Travers.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
and that's the whole page, bestie π this one was generated by perl v5.36.0 on 2022-12-02, and yes it's the one and only PGObje...eudoCSV(3pm) β iconic, no notes π β¨
π¦ where this page comes from
- debian bookworm: libpgobject-util-pseudocsv-perl 2-2 Β· BSD-2-Clause
- debian trixie: libpgobject-util-pseudocsv-perl 2-2 Β· BSD-2-Clause
- ubuntu noble: libpgobject-util-pseudocsv-perl 2-2 Β· BSD-2-Clause
- ubuntu resolute: libpgobject-util-pseudocsv-perl 2-2 Β· BSD-2-Clause
- ubuntu stonking: libpgobject-util-pseudocsv-perl 2-2 Β· BSD-2-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms