Tie::File::AnyData::MultiRecord_CSV - Accessing groups of CSV records in a file via a Perl array.
use Tie::File::AnyData::MultiRecord_CSV; ## Suppose a CSV file containing the following data: # gene1 134123 541354 ini # gene1 134125 614513 mid1 # gene1 164151 661451 mid2 # gene1 214315 233415 fin # gene2 313415 614351 ini # gene2 341513 341566 fin # gene3 512341 665144 ini # gene3 551645 667676 ini # gene3 661445 777347 mid # gene3 888513 918344 fin tie my @data_array, 'Tie::File::AnyData::MultiRecord_CSV', $datafile or die $!; print "$data_array[0]"; # prints: # gene1 134123 541354 ini # gene1 134125 614513 mid1 # gene1 164151 661451 mid2 # gene1 214315 233415 fin untie @data_array; ## All the array operations are allowed: push @data_array, $rec; ## Append a CSV records at the end of the file unshift @data_array, $rec; ## Put CSV records at the beginning of the file my $rec = pop @data_array; ## Remove the last group of CSV records of the file (assigned to $rec) my $rec = shift @data_array; ## Remove the first group of CSV records of the file (assigned to $rec) ... and so on.
Tie::File::AnyData::MultiRecord_CSV allows the management of groups of CSV records in a file via a Perl array through Tie::File::AnyData, so read the documentation of the latter module for further details on its internals. For the management of CSV records it uses the Parse::CSV module.
Tie::File::AnyData::MultiRecord_CSV
Tie::File::AnyData
Parse::CSV
A group of CSV records is defined by some CSV lines that have a common key field. For example, if you have the following group of CSV lines in a file:
aa1 bb1 cc1 aa1 bb1 cc2 aa1 bb2 cc3 aa1 bb2 cc4 aa2 bb3 cc5
Then, if you take key = 0 (first field), then, the fist record would be: aa1 bb1 cc1 aa1 bb1 cc2 aa1 bb2 cc3 aa1 bb2 cc4
With key = 1 (seconf field), the first record would be: aa1 bb1 cc1 aa1 bb1 cc2
Finally, with key = 2 (third field), then, the first record would be: aa1 bb1 cc1
This module accepts the same parameters as Tie::File plus:
Tie::File
Miguel Pignatelli Please send any comment to: motif@pause.org The most recent version of this module, should be available at CPAN.
Please report any bugs or feature requests to bug-tie-file-anydata-multirecord_csv at rt.cpan.org, or through the web interface at http://rp.cpan.org/NoAuth/ReportingBug.html?Queue=Tie-File-AnyData-MultiRecord_CSV.
bug-tie-file-anydata-multirecord_csv at rt.cpan.org
You can find documentation for this module with the perldoc command:
perldoc Tie::File::AnyData::MultiRecord_CSV
Copyright 2007 Miguel Pignatelli, all rights reserved.
This library is free software; you may redistribute it and/or modify it under the same terms as Perl itself.
This module comes with ABSOLUTELY NO WARRANTY.
To install Tie::File::AnyData::MultiRecord_CSV, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Tie::File::AnyData::MultiRecord_CSV
CPAN shell
perl -MCPAN -e shell install Tie::File::AnyData::MultiRecord_CSV
For more information on module installation, please visit the detailed CPAN module installation guide.