Page 1 of 1

Split the Record...

Posted: Wed Sep 07, 2011 5:26 am
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

Re: Split the Record...

Posted: Wed Sep 07, 2011 6:56 am
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.

Posted: Wed Sep 07, 2011 5:33 pm
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