NAME
Tie::File::AnyData::MultiRecord_CSV - Accessing groups of CSV records in a file via a Perl array.
SYNOPSIS
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.
DESCRIPTION
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.
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
PARAMETERS
This module accepts the same parameters as Tie::File
plus:
- field_sep : The character used to separate fields in the input file (defaults to "\t").
- key : A number indicating the field that defines a group of CSV lines (defaults to "0").
AUTHOR
Miguel Pignatelli
Please send any comment to: motif@pause.org
The most recent version of this module, should be available at CPAN.
BUGS
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.
You can find documentation for this module with the perldoc command:
perldoc Tie::File::AnyData::MultiRecord_CSV
LICENSE
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.
WARRANTY
This module comes with ABSOLUTELY NO WARRANTY.