Here is a possible idea that could work (I'll leave it up to you to implement it)

Assumption: one record is stored on each line (or you know exactly how many lines define one record).

Idea: Create a hash which represents the charachters and the numbers of lines they appear on. (Which means: read the file record per record, and add 1 to the correct hash-element for each unique charachter).

Now look for the charachters that occurs on every line. (meaning loop the hash and look for the elements where the value equals the total number of lines (after excluding alphanumeric charachters etc))

Now when you are done with that, then you might or might not be there yet. As in, what if there are two charachters that appear on every line? A solution for this could be that you try each charachter as a delimiter, and count how many fields you get... if there is a big difference in the number of fields then there is a big chance you used the wrong delmiter (except ofcourse when the data is really strange)


In reply to Re: delimited files by Animator
in thread delimited files by saldoman

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.