Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^2: RFC: Tie::File::AnyData Lightweight Databases in Perl

by citromatik (Curate)
on Dec 11, 2007 at 10:19 UTC ( #656367=note: print w/replies, xml ) Need Help??


in reply to Re: RFC: Tie::File::AnyData Lightweight Databases in Perl
in thread RFC: Tie::File::AnyData Lightweight Databases in Perl

... what has got the example to do with CSV?

Well, in fact, a more correct name would be multilineCSV. This module takes several consecutive lines of fields (CSV, tabular, or whatever) that have the same value in a given field (the "key" field") and joins them in one logical record.

Well, I think that it has to do with CSV at least because internally it uses Parse::CSV to parse the lines.

Let's consider the following example:

Mike,5,6 Mike,5,3 John,5,1 John,3,0 Frank,6,1

Using this code:

use Tie::File::AnyData::CSV; tie my @arr,'Tie::File::AnyData::CSV', key=>0, field_sep => ","; print "$arr[0]\n"; ## prints # Mike,5,6 # Mike,5,3 untie @arr; tie my @arr2,'Tie::File::AnyData::CSV', key=>1, field_sep => ','; print "$arr[0]\n"; ## Prints # Mike,5,6 # Mike,5,3 # John,5,1

In the first case, all consecutive lines that have the same value in the first field ("Mike" in the key field), are considered a record. In the second case, all consecutive lines that have the same value in the second field ("5") are considered a record

From Tie::File::AnyData::CSV I would expect to get a tied array of arrays or array of hashes that'd let me access the individual items in the rows. And hopefully the ability to include the record separator within quoted data. Please find a better name for that format.

Hmmm, totally agree, I will try to change that name

Thanks for your comments!

citromatik

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://656367]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2019-04-26 07:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I am most likely to install a new module from CPAN if:
















    Results (128 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!