problem in reading variable number of columns from 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
elias.shaik
Participant
Posts: 51
Joined: Sat Dec 09, 2006 3:32 am

problem in reading variable number of columns from file

Post by elias.shaik »

Hi all,

Would you please let me know if there is a way to read variable number of columns from a sequential file
.


Sample data:

Code: Select all

"abc","yui",123,"rty"
"ois","ght",45,
------------
Elias
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Your example has 4 columns in both rows.
elias.shaik
Participant
Posts: 51
Joined: Sat Dec 09, 2006 3:32 am

Post by elias.shaik »

sorry typo mistake.Here is the correct sample of records

Code: Select all

"abc","yui",123,"rty","mnb"
"ois","ght",45
------------
Elias
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

This is tougher to do in PX than in server - I would use a server job, where missing columns at the end of a line can be handled automatically - a functionality not present in PX jobs. The Server job could read & reformat the file and then a PX job could do the real processing.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

About the only way I can think of (apart from using cascading reject links on Column Import stages) is to read the entire line as a single VarChar field and parse it using Field() functions in a Transformer stage. Missing fields will return "" from the Field() function; you can do with these what ever you wish. You can also count the delimiters (in a stage variable) to check whether the field is truly missing or validly empty.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Sreenivasulu
Premium Member
Premium Member
Posts: 892
Joined: Thu Oct 16, 2003 5:18 am

Post by Sreenivasulu »

Use schema files.
With this input column are mapped to their respective database column irrespective of the position.
Hope this helps

Regards
Sreeni
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Except in this case the source is a sequential file.
keshav0307
Premium Member
Premium Member
Posts: 783
Joined: Mon Jan 16, 2006 10:17 pm
Location: Sydney, Australia

Post by keshav0307 »

Read as a single column and in a transformer use the FIELD function to split
Post Reply