Fixed width files

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
puli.reddy
Participant
Posts: 28
Joined: Wed Jan 11, 2006 8:29 pm
Location: Singapore
Contact:

Fixed width files

Post by puli.reddy »

Hi All,

I am working with datastage version 7.0. I am facing a problem to read data from fixed width files using sequential file stage.
I am giving you my input file as follows..
Col1 Col2 Col3
100 ABC 213
101 DEF 12345
102 GHI 432

Please notify that my first row terminates after 213. There is no spaces/blank values.
If I define Col3 as varchar(3) it will be giving giving error as follows...
GettingSrcFileFormat..Sequential_File_0.DSLink3: read_fixedwidth() - row 1, column Col3, column unexpectedly ended by EOR.

I tried by increasing the size but that wasn't working.

My expected result would be like as follows..
Col1 Col2 Col3 Col4
100 ABC 213 Null
101 DEF 123 45
102 GHI 432 Null

Anyone of you can help me to resolve this issue.

Thanks in advance.
Last edited by puli.reddy on Wed Jan 25, 2006 1:48 am, edited 1 time in total.
Thnaks and Regards,
AnjiReddy.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Your file is not fixed-width format or in a different format than you think. In order for it to be fixed width it would need spaces (otherwise your line 1 and line 2 would have different lengths!). It has EOR (end-of-record) terminators and one was encountered while parsing your input data.

You need to use an editor to look at your actual data format and then change your PX job to make it reflect that format.
puli.reddy
Participant
Posts: 28
Joined: Wed Jan 11, 2006 8:29 pm
Location: Singapore
Contact:

Thnaks

Post by puli.reddy »

Thnaks for your reply. I know its not fixed width, How can we overcome such issues by using data stage. Can you tell me in detailed manner.
Thnaks and Regards,
AnjiReddy.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Re: Fixed width files

Post by ArndW »

Puli.reddy,

in your first post you stated
puli.reddy wrote:...I am facing a problem to read data from fixed width files...
and now you are stating that you know the file is not fixed width? If you declare your column definitions correctly and also specify the correct sequential file attributes (column separators, line terminators, etc.) you will read the file. I can't answer your question since you haven't really told us what your problem is!

The error message means that you have declared the line to be longer than it actually is - since an EOR was encountered. This error message also tells you what position in the line it was as (you didn't post that part), that will help you diagnose what declaration is wrong.

Using sequential files in PX can be a bit more work to set up and get running than with Server jobs, but it remains a relatively simple task.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

If you edit the table definition that you imported, you will find that the physical column width is stored as Display Width. Or you can use the Edit Row facility to specify the column widths explicitly.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
puli.reddy
Participant
Posts: 28
Joined: Wed Jan 11, 2006 8:29 pm
Location: Singapore
Contact:

Re: Fixed width files

Post by puli.reddy »

Arnd, Only last column isn't fixed width remaining all are fixed only. I have a requirement to consider it as fixed width. It was solved by using excel workbook. I imported srcfile into excel and saved it as delimiter. Later I took source as csv and achieved what I require.

Thanks.

I would welcome another solution to resolve this by using datastage with out using excel.
Thnaks and Regards,
AnjiReddy.
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

If one column is not fixed width then the file cannot be fixed width. Your requirements to consider the sequential file as fixed width don't change that fact. If you saved the file from Excel then it is a variable length delimited file, and you should declare it as such in PX.

You need to know your original source declaration. If all columns are fixed width except the last one declare it that way. For example, col 1 is CHAR(3), col 2 is CHAR(3) and the last column is VARCHAR(10). PX will interpret the columns correctly. Are the columns delimited?
Post Reply