Text::ECSV - Extended CSV manipulation routines
use Text::ECSV; $ecsv = Text::ECSV->new (); # create a new object $line = 'id=3,name=Text::ECSV,shot_desc=Extended CSV manipulation routines'; $status = $ecsv->parse ($line); # parse a CSV string into fields # and name value pairs %columns = $ecsv->fields_hash (); # get the parsed field hash $column = $ecsv->field_named('id'); # get field value for given name $ecsv->combine('b' => 2, 'a' => 1, 'c' => 3, ); # ok($ecsv->string eq 'b=2,a=1,c=3');
use base 'Text::CSV_XS'; => see Text::CSV_XS.
Roland Giersig had a presentation at YAPC 2007 called 'Techniques for Remote System-Monitoring'. He was explaining his search after a good logging format or how to store continuous flow of data in a most usable form. XML? YAML? CSV? XML is nice but for a machines not for humans, YAML is nice for both but it's hard to grep. CSV is readable and grep-able but not too flexible. So what is the conclusion? ECSV is like a CSV but in each comma separated field the name of the column is set. This gives a flexibility to skip, reorder, add the fields. All the information is stored per line so it's easy to grep. Also it's easy to compare two records by md5-ing the lines or doing string eq.
Holds hash reference to the resulting hash constructed by
If set and a dupplicate key names occure in a parsed line, this strategy is called with
->($name, $old_value, $value).
Can be used for duplicate keys to join values to one string, or push them to an array or to treat them how ever is desired. By default values overwrite each other.
Return field with $name.
In aditional to the
SUPER::parse() functionality it decodes name value pairs to fill in
The function joins all $key.'='.$value and then calls
SUPER::combine constructing a CSV from the arguments, returning success or failure.
<firstname.lastname@example.org>, thanks to Roland Giersig
<RGiersig@cpan.org> for the idea.
Please report any bugs or feature requests to
bug-text-ecsv at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Text-ECSV. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
You can also look for information at:
Copyright 2008 Jozef Kutej, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.