Reading the sequential file

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
halpavan2
Participant
Posts: 31
Joined: Fri Apr 18, 2008 5:44 am
Location: Hyderabad

Reading the sequential file

Post by halpavan2 »

Hi All,

I have source file say file.csv where it contains following data

Empno, Deptno
12,1
13,1
23,2
45,3

now my requirment is when i read this file in datastage it should read only the records where Deptno=1,2...not every time 1 and 2 the Deptno will keep on changing.

I am thinking that i will create a file in unix for which Deptno should process the read the records mentioned in below file.

like dept.txt contains 1,2

Can i use the file in datastage to read only the deptno mentioned in the file. is it possible ot how can achieve this.

Pavan
pavan
sinhasaurabh014
Participant
Posts: 86
Joined: Wed Apr 02, 2008 2:32 am
Location: Bangalore

is it filter

Post by sinhasaurabh014 »

Hi
Not sure what you are trying to say in the last few lines but if your requirement is to put filter while reading the sequential file you may use oany of the two options
1. Use Sequential File to read complete set of data and use filter stage to filter out records. Use parameters to change the department value

2. Use sequential stage to read data and use filter option in the sequential file stage itself-use unix commands like sed or awk to filter on records, when you use this option try to see if you can parametrize the values that you want to put filter on. I am sure this will work.

The second option may or may not be faster than the first option as anyhow every record has to be read and suitable filter applied. The first option is neater.

Let us know how you approach and its outcome.
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Just to get anal and all nit-pick-itty, one cannot only 'read' certain records from a sequential file. It's called that for a reason and records from sequential media must be read from beginning to end, it's the nature of the beast. You may only want to process certain ones, which means via a contraint or a filter, but all must be read.
-craig

"You can never have too many knives" -- Logan Nine Fingers
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Alternatively you can have an operating system command, such as grep or awk, select the rows for you. You would implement this by means of a Filter command in the Sequential File stage.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
bhasds
Participant
Posts: 79
Joined: Thu May 27, 2010 1:49 am

Reading the sequential file

Post by bhasds »

Hi Halpavan2,

The below command in filter option in sequential file stage should give you the result as said by Ray-

Code: Select all

awk -F","  '{if ($2==1 || $2==2) print $0}'
Post Reply