Do you want your "sample" to have mock records that show all field variants, or do you want to sample real records?

If you're mocking records, read your data files and for each field track each variant. A hash of hashes would work well for this. See perldsc if you're not familiar with the HoH. Then you pick the field with the most variants, and that's how many records you have to have. Loop over them all, generating a record for each. The record generator will look at every other field and pick a variant that hasn't been shown yet or a random one if they've all been shown.

If you're sampling real records, it's more complicated. You still need to have a record of every variant for every field, but for each of those you need a list of the records that provide an example. I would start with records that appear least frequently in the data structure. That is, pick a record that gives an example of a variant that doesn't appear very often. It will also have examples of more common field variants. Upon picking that record, "mark off" the variants that you've exemplified already. Keep picking records that show the least common remaining variant until you've exemplified them all.

In case it's not obvious, I think the important part of this problem is the data structures you use to store your input data. You want something that will lead you naturally to the records you want.


In reply to Re: Most efficient record selection method? by kyle
in thread Most efficient record selection method? by Kraythorne

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.