Page 1 of 1

problem in reading variable number of columns from file

Posted: Tue Sep 29, 2009 3:59 am
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,

Posted: Tue Sep 29, 2009 4:05 am
by ArndW
Your example has 4 columns in both rows.

Posted: Tue Sep 29, 2009 4:21 am
by elias.shaik
sorry typo mistake.Here is the correct sample of records

Code: Select all

"abc","yui",123,"rty","mnb"
"ois","ght",45

Posted: Tue Sep 29, 2009 6:49 am
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.

Posted: Tue Sep 29, 2009 4:22 pm
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.

Posted: Wed Sep 30, 2009 1:12 am
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

Posted: Wed Sep 30, 2009 2:41 am
by ArndW
Except in this case the source is a sequential file.

Posted: Wed Sep 30, 2009 6:22 pm
by keshav0307
Read as a single column and in a transformer use the FIELD function to split