Split the Record...

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
praburaj
Premium Member
Premium Member
Posts: 133
Joined: Thu Jun 30, 2005 1:26 am
Location: philippines

Split the Record...

Post by praburaj »

Hi All,

I have one flat file which has 3 columns. I have mentioned below the metadata of the file.

ColumnName DataType

Name Varchar 6
Salary Varchar 6
Company Varchar 6

My problem is There is no delimiter in any one of the records. All the records are in sameline.

Ex:
Pravin50000GoogleMoses70000Target

Above I mentioned just for 2 records. Like that It may have many number of records.

Now I need to split the each record one by one and store the corresponding records into corresponding columns.

Hope I have clearly explained my problem to you people

Any help is really appreciated.

I need my output

Name Salary Company

Pravin 50000 Google
Moses 70000 Target

This file is a fixed length
prabakaran.v
BI-RMA
Premium Member
Premium Member
Posts: 463
Joined: Sun Nov 01, 2009 3:55 pm
Location: Hamburg

Re: Split the Record...

Post by BI-RMA »

praburaj wrote:This file is a fixed length
Hi praburaj,

can't be: If You can have hundreds of tuples within a single line, the line will most likely not be fixed length. If the tuples themselves are, then read the file in fixed-length mode and your problem is solved.
"It is not the lucky ones are grateful.
There are the grateful those are happy." Francis Bacon
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Is the Capitalization always as you show? Then a before-job subroutine (or a routine invoked from a Routine activity in a sequence) could pre-process the data stream into a "regular" file with one record per line.

Algorithm (first guess)
Read entire file as a string.
Pre-read the first Name and Salary
Read the next CompanyNameSalary string

Code: Select all

MatchField(TheString, "0A0N0X",1) : MatchField(TheString, "0A0N0X", 2)
Concatenate
Process the tuple

Code: Select all

Name is MatchField(Tuple, "0A0N0A", 1)
Company is MatchField(Tuple, "0A0N0A", 3)
Salary is MatchField(Tuple, "0A0N0A", 2)
Adjust the string and tuple but removing what was just processed from the left hand end.
Write tuple to new file.
Repeat until end of file
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply