Page 1 of 1

Reading tab delimated file, encountering problem

Posted: Mon Nov 26, 2012 9:28 am
by smohd1338
Hi,

I am reading a file with multiple records.Each column in a single record is TAB delimated.

the input file looks like this below:(the space btw is TAB)
FH column1 column2 column3
BH Column1 Column2 Column3
DS Column 1 Column2 Column3
DL...etc.

To read each column i gave this logic in transformer by putting respective constraints on recordType.

Field(Extract_lnk.LogRecord,Char(9),1)
and like wise, Field(Extract_lnk.LogRecord,Char(9),2).....

the logic is working fine as long as there is only one long string, but if they are strings with spaces between them, then the datastage is considering them as 2 columns, like in the DS record in column1 is with space as column and 1, so it is reading in 2 different columns(despite it being space and not tab)? how shall this be resolved, any ideas

Posted: Mon Nov 26, 2012 10:51 am
by ArndW
How did you define your sequential file - as one column or as multiple columns? The definition is where your problem lies.

Posted: Mon Nov 26, 2012 11:04 am
by smohd1338
Ia m reading such 3 files, so read in file pattern manner, and there would be one long log record. YES as one column.

Posted: Mon Nov 26, 2012 12:48 pm
by ArndW
In that case, the "Field(In.BIGColumn,Char(9),1)" will parse the string until the first tab character, skipping past any and all spaces in the string, until it gets to the first TAB character and will return what is to the left of it as the function return value.

you can confirm this by writing a test job which writes to a peek stage, output your source "In.BIGColumn" record and another column with the derivation of "INDEX(In.BIGColumn,Char(9),1)" to show you the position of the first tab. Perhaps what you assumed to be a space was actually a TAB character.

Posted: Mon Nov 26, 2012 3:36 pm
by ray.wurlod
Is there any reason you're not using TAB as the field delimiter character in the Sequential File stage?