Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
... 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

In reply to Re^2: RFC: Tie::File::AnyData Lightweight Databases in Perl by citromatik
in thread RFC: Tie::File::AnyData Lightweight Databases in Perl by citromatik

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2024-04-23 10:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found