I am trying to split a bunch of files..

Attached are 2 Raw Files. One is Joint and the other is Single.

  1. I need to separate Joint and Single into Separate Directory.
  2. Out of the Joint i need to create single files again but i need to keep the Key identifier which is 15bytes long starting from 11th byte at the begining of the file(322418208360600) for each joint file too.

Characteristics: Header: TU4R+21bytes(starting from 11th byte onwards upto 15 bytes i.e;322418208360600) is the key for each file.

Tail: ENDS+6bytes.

1) How to identify the joint accounts-
Criteria: After the First Occurance of 'SC01'(+30bytes) If 'SH01' occurs then its a joint account).

For all such patterns i need to separate from SH01(after 'SC01') until the next occurance of 'SC01'(+30bytes) as another file but i need to retain the 'TU4R'(+21bytes-which includes the key identifier even in the second file!

Hope this helps a lot.

Any ideas?? A) Sample Joint File-

TU4R062011322418208360600 06TRR 0000141020020923102648PH +0101207000SH01027101Y05N32QUN19771201NM01070F1FIACOMMON + JOHN E PI01029F08682001819420201 AD +01105F1138 CAMINO FANTASY ISLAN +D IL60750 20000301AD01105F11117 POB 117 + WATER MILL NY11976 1999090 +1AD01105F1130 POB 30 WATER HILL + NY11976 PN01027F109 7269551 EM011 +00ECU FE + 20020901R EM01100EMPRESS CASINO F + 20020901R AO01017009500 +1 SC0103400950+728 010005030008 SH01027101Y05N32QUN19771201NM01070F1FIACOMMON JOHN + E PI01029F08682001919420201 AD01105F1138 + CAMINO FANTASY ISLAND + IL60750 20000301AD01105F11117 AO010170095001 SC +0103400950+738 010005030008 ENDS010052
B) Sample- Single File!
TU4R062011322418208360601 06TRR 0000141020020923102648PH +0101207000SH01027101Y05N32QUN19771201NM01070F1FIACOMMON + JOHN E PI01029F08682001819420201 AD +01105F1138 CAMINO FANTASY ISLAN +D IL60750 20000301AD01105F11117 POB 117 + WATER MILL NY11976 1999090 +1AD01105F1130 POB 30 WATER HILL + NY11976 PN01027F109 7269551 EM011 +00ECU FE + 20020901R EM01100EMPRESS CASINO F + 20020901R AO01017009500 +1 SC0103400950+718 010005030008 ENDS010052
Edited by castaway added a bunch of html formatting.

In reply to Identifying if the File is Single or Joint! by kris2000

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.