Hi All,
A nice easy one being an extension of two previously answered questions. Should be nice easy points up for grabs.
For reference see the following two PAQ's:
First Question:
http://www.experts-exchange.com/Programming/Programming_Platforms/Unix_Programming/Q_21763311.htmlSecond Question:
http://www.experts-exchange.com/Programming/Programming_Platforms/Unix_Programming/Q_21764891.htmlThe input is ever so slightly different, and the output required is ever so slightly different.
Ozo's answer from the second PAQ is great - it works.
So can base off this or re-work if you like.
--------------------------
----------
------
INPUT ATTRIBUTES:
* Text file to be split into multiple files
* Delimeters start with two consecutive pipes and consist of 7 pipes
DELIMITER EXAMPLES:
a) ||XX|123456|A111|||
b) ||XX|123456|A111|021234567
8||
c) ||XX|123456|A111|(02) 12345678||
d) ||XX|123456|A111|(02) 12345678|test@email.com|
a) The first example are the only compulsory fields
XX=company code
123456=booking which could be 5 or 6 digits
A111=series which is letter and number combo
b) Also contains a phone number
c) The phone number can contain spaces and brackets
d) Also can contain email address
AIM:
* To convert text file into multiple text files based on file names above
* Filenames should be unique
* Filenames should unclude YYYYMMDD_HHMM to ensure uniqueness
* Files produced should maintain the pipe delimiter as line number one
* Junk text found in file prior to first pipe should be discarded
INPUT FILE EXAMPLE:
VVVVVVVVVVVVVVVVVVVVVVVVVV
Possible junk text to be discarded
||AA|111111|E123|||
Contents of file one
||XX|222222|A111|(02) 12345678||
Contents of file two
||XX|222222|A111|021234567
8||
Contents of file three
^^^^^^^^^^^^^^^^^^^^^^^
OUTPUT FILES PRODUCED:
AA111111_20060518_1614_001
.DOC
XX222222_20060518_1614_002
.DOC
XX222222_20060518_1614_003
.DOC
NOTE:
AA111111_20060518_1614_001
.DOC would contain:
VVVVVVVVVVVVVVVVVVVVVVVVVV
||AA|111111|E123|||
Contents of file one
^^^^^^^^^^^^^^^^^^^^^^^
Thanks in advance,
Start Free Trial