Reading multiple files with header

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
sweta rai
Participant
Posts: 14
Joined: Tue Apr 01, 2008 6:56 am
Location: kolkata

Reading multiple files with header

Post by sweta rai »

Hi everyone ,

I am using a sequential file stage . and reading multiple files with Read Method set as "File Pattern" . The problem which i'm facing is .....all files are having header in it , although i'm specifying "First Line is Column Name" to TRUE ..... the header is also getting inserted into the target except the first file's header .
I do not want to edit the multiple source files (like removing the header from each of them) .

I do not find the solution in previous posts for this problem . If anybody knows... kindly provide the solution .
Sweta
nani0907
Participant
Posts: 155
Joined: Wed Apr 18, 2007 10:30 am

Post by nani0907 »

In sequential file we have a filter option we can filter the header using below command.

sed'1d'.


let me know how it works.

Thanks
Sana.
thanks n regards
nani
nani0907
Participant
Posts: 155
Joined: Wed Apr 18, 2007 10:30 am

Post by nani0907 »

In sequential file we have a filter option we can filter the header using below command.

sed'1d'.


let me know how it works.

Thanks
Sana.
thanks n regards
nani
sweta rai
Participant
Posts: 14
Joined: Tue Apr 01, 2008 6:56 am
Location: kolkata

Post by sweta rai »

@ nani0907

Yes it worked .But the "Filter" option is not available if the Read Method is "File Pattern" and not "Specific File(s)" .

In my case , the number of files are varying ...so i have to use "File Pattern" only to read multiple files.

So, what needs to be done in this scenario ?
Sweta
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Allow a reject link to capture the headers.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sweta rai
Participant
Posts: 14
Joined: Tue Apr 01, 2008 6:56 am
Location: kolkata

Post by sweta rai »

Ya , that could be done .. but all the columns in source are of varchar type so ..it smoothly getting transferred to the output .

Anyways .. i can handle that partcular header record in the transformer but i wanted to know is not there any option available in sequential file stage itself like the Filter thing ??
Sweta
kpsita
Participant
Posts: 99
Joined: Tue Jul 21, 2009 11:43 pm

Post by kpsita »

Hi,

I am facing same issue. I did you handle this issue in transformer.

Thanks
KPSITA
varunndschange
Participant
Posts: 4
Joined: Mon Jul 05, 2010 1:21 am

Post by varunndschange »

You are reading multiple files from file pattern. Consider, if fields f1, f2, f3 and so on are there in files. Now go to filter stage and there set the condition as:
f1<>'f1'. This way only file records will be passed, not the column names.

E.g.
file1: f1, f2, f3
1, 1, 1
2, 2, 2

file2: f1, f2, f3
3,3,3
4,4,4

file3: f1, f2, f3
5,5,5
6,6,6

When you read the file pattern, records will come like as:

f1, f2, f3
1, 1, 1
2, 2, 2
f1, f2, f3
3,3,3
4,4,4
f1, f2, f3
5,5,5
6,6,6

Now, in filter stage if you define the constraint like this:
f1<>'f1'
Then from output link of filter you will get the result as:
1, 1, 1
2, 2, 2
3,3,3
4,4,4
5,5,5
6,6,6
.

Hope this solves your purpose
Varun Negi
Assistant System Enginner
TCS
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If it suits your requirements, the easiest solution is to use multiple File properties rather than read method "file pattern".
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