Readin data

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
swerajan
Participant
Posts: 42
Joined: Tue Aug 05, 2008 4:34 am

Readin data

Post by swerajan »

Hi
I have a sequential file with 2 columns and delimited by ~ .
If the data in the file is somthingike this
Name~Balance
~~~2000
Are there any ways to read the first 2 ~ into the first column and place the balance amount in the balance column?
kiran259
Participant
Posts: 48
Joined: Thu Aug 16, 2007 11:17 pm
Location: United States
Contact:

Post by kiran259 »

Is the quote "none" here? else single or double quote present.


Kiran Vaduguri
Kiran Vaduguri

As soon as the fear approaches near, attack and destroy it.
swerajan
Participant
Posts: 42
Joined: Tue Aug 05, 2008 4:34 am

Post by swerajan »

There are no quotes there in the file. !! It is a file from mainframe system without quotes
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Declare the file as a long VarChar() or Char() string with no delimiters. Then, in a transform stage, use function such as DCOUNT() and FIELD() to parse the string into the 2 components you wish.
swerajan
Participant
Posts: 42
Joined: Tue Aug 05, 2008 4:34 am

Post by swerajan »

Actually i missed out a point in my question.
The data would look somehting like this. even if it comes likes this i need to handle it in the ETL. Will the same logic of yours work for this scenario Arnd?
Name~Balance
~~~2000
sss~9000
bbb~1000
swerajan
Participant
Posts: 42
Joined: Tue Aug 05, 2008 4:34 am

Post by swerajan »

Actually i missed out a point in my question.
The data would look somehting like this. even if it comes likes this i need to handle it in the ETL. Will the same logic of yours work for this scenario Arnd?
Name~Balance
~~~2000
sss~9000
bbb~1000
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Yes, but you need to handle this in your transform. With DCOUNT(In.String,'~') you find out how many tilde you have, then with FIELD(In.String,'~',nnn) you can pick out field nnn from the string. The rest is up to you and your business logic.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Why not just have your Mainframe folks stop providing you with an invalid file? Meaning, correct the delimiters so you don't have to screw around like that. :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
kiran259
Participant
Posts: 48
Joined: Thu Aug 16, 2007 11:17 pm
Location: United States
Contact:

Post by kiran259 »

Swerajan:Did you get the solution?

Arnd:Even if I count no. of tildes,FIELD function looks into delimeter,how can I distinguish starting two tildes with actual delimeter '~'?Could not see complete post because of premium member constraints. :(
Kiran Vaduguri

As soon as the fear approaches near, attack and destroy it.
srinivas.g
Participant
Posts: 251
Joined: Mon Jun 09, 2008 5:52 am

Post by srinivas.g »

FIELD(In.String,'~',2) -->name clumn
FIELD(In.String,'~',3) --->balance column
Srinu Gadipudi
srinivas.g
Participant
Posts: 251
Joined: Mon Jun 09, 2008 5:52 am

Post by srinivas.g »

FIELD(In.String,'~',2) -->name clumn
FIELD(In.String,'~',3) --->balance column
Srinu Gadipudi
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Actually, more like:

Code: Select all

FIELD(In.String,'~',1,DCOUNT(In.String,'~')-1) -->name clumn 
FIELD(In.String,'~',DCOUNT(In.String,'~')) --->balance column 
Post Reply