Variable length of columns in text file

Post questions here relative to DataStage Server Edition for such areas as Server job design, DS Basic, Routines, Job Sequences, etc.

Moderators: chulett, rschirm, roy

Post Reply
malin666
Participant
Posts: 19
Joined: Wed Jan 18, 2006 10:16 am

Variable length of columns in text file

Post by malin666 »

Hi,
I have a text file where are variable length columns.

for example

first two characters is id
next 10 characters is name
next 20 characters is address
etc

How to import such data in to the table definitions?
I see there only option of fixed width columns and delimited ones?

None of them is correct in my case :(

Any help would be much appreciated.
Marcin
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

open the file in a notepad, what delimitter do you see? do you even see any delimiter?
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
seanc217
Premium Member
Premium Member
Posts: 188
Joined: Thu Sep 15, 2005 9:22 am

Post by seanc217 »

Is the ID field actually the length of the variable data?
I have files that do this.
malin666
Participant
Posts: 19
Joined: Wed Jan 18, 2006 10:16 am

Post by malin666 »

DSguru2B wrote:open the file in a notepad, what delimitter do you see? do you even see any delimiter?
No, it is not a delimited file.

As I said from the specification I know that
first 2 characters is id, next 10 name, etc...

Best regards
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Then it is a 'fixed width' file and should be imported as one.
-craig

"You can never have too many knives" -- Logan Nine Fingers
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

then your file is of fixed width format.
do this, while importing the meta data, choose the fixed width option and in the columns, specify the column name and in the length specify the ( for ID specify 2, for name specify 10 and so on...).
this should work, provided your file is truely fixed width.
when i say truely fixed width, i mean, even if the name is of length 5, the rest of the remaining 5 positions should be empty spaces)
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
Post Reply