read all files from load directory

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
kaushal.kumar@igate.com
Participant
Posts: 77
Joined: Tue Apr 14, 2009 4:03 am

read all files from load directory

Post by kaushal.kumar@igate.com »

i have to read all file with file name from load directory.In each run number of file may vary.all files are fixed width length file.
say for example below are my files in load directory( may be in next run i will have more files)
1_20100311_171556.txt
2_20100311_171556.txt
3_20100311-171556.txt
4_20100311-171556.txt
5_20100311-171556.txt
please advice me how to read files in my job when i don't know the number of files which we have in load directory :(
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

'Read' in what sense? If you are required to process them one by one, build a looping Sequence job. Otherwise, cat them all together (before job or in the Filter option) and 'read' them as one big file.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kaushal.kumar@igate.com
Participant
Posts: 77
Joined: Tue Apr 14, 2009 4:03 am

Post by kaushal.kumar@igate.com »

chulett wrote:'Read' in what sense? If you are required to process them one by one, build a looping Sequence job. Otherwise, cat them all together (before job or in the Filter option) and 'read' them ...
i have to process them one by one and i need to know file name as well.
please advice
Sreenivasulu
Premium Member
Premium Member
Posts: 892
Joined: Thu Oct 16, 2003 5:18 am

Post by Sreenivasulu »

Run as follows

ls(comand activity. ls with appropriate option) ->startloop->Uservariable(read the output of ls) ->Job->endloop

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

Post by chulett »

In other words, a looping Sequence job. :wink:
-craig

"You can never have too many knives" -- Logan Nine Fingers
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Can you not try using a file pattern in the sequential file stage, which will also give you the file name as an additional column if you so desire.
kaushal.kumar@igate.com
Participant
Posts: 77
Joined: Tue Apr 14, 2009 4:03 am

Post by kaushal.kumar@igate.com »

Sreenivasulu wrote:Run as follows

ls(comand activity. ls with appropriate option) ->startloop->Uservariable(read the output of ls) ->Job->endloop

Regards
Sreeni
hi Sreenivasulu,

will this job read all file record and file name one by one :?:
please advice
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Ack... parallel job. Yes, what Arnd suggested could be an option as well, depending on how tight that 'process one by one' requirement has you in its grasp.
-craig

"You can never have too many knives" -- Logan Nine Fingers
kaushal.kumar@igate.com
Participant
Posts: 77
Joined: Tue Apr 14, 2009 4:03 am

Post by kaushal.kumar@igate.com »

ArndW wrote:Can you not try using a file pattern in the sequential file stage, which will also give you the file name as an additional column if you so desire. ...
in sequential file i have defined
file patern=#$LoadDir#\*.*
in option properties i have defined
file name column-xyz
now i have doubt..in column tabb do i need to define column
file name ?
details

actually i have defined only one column from which i am getting only record :cry:
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

In the sequential file properties tab, click on 'options' and you'll see that you have a property call 'File Name Column', activate that and choose the column name that you would like to use.
kaushal.kumar@igate.com
Participant
Posts: 77
Joined: Tue Apr 14, 2009 4:03 am

Post by kaushal.kumar@igate.com »

ArndW wrote:In the sequential file properties tab, click on 'options' and you'll see that you have a property call 'File Name Column', activate that and choose the column name that you would like to use. ...
hi ArndW ,
i have used 'File Name Column'=xyz.
but in output i am not getting my file name which i have in load directory(sample.txt)
in xyz column its returning load directory path .
please advice :cry:
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

-craig

"You can never have too many knives" -- Logan Nine Fingers
Post Reply