Folder Stage

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
asvictor
Participant
Posts: 31
Joined: Tue Sep 02, 2003 3:06 am
Location: Singapore
Contact:

Folder Stage

Post by asvictor »

Hi,

I tried using Folder stage in my job to use a set of Files in a folder and post in a seq File / Table. it is a CSV file. When I run the Job, I either get only the Column Names or Column Names and fields in the Resulting File. How do I use the Folder stage to Extract the required Fields

Victor Auxilium
raviyn
Participant
Posts: 57
Joined: Mon Dec 16, 2002 6:03 am

Post by raviyn »

Does this set of files have same Metadata.Then you can go for a two step job like in the first job using folder stage u get the filenames , and then use this as an parameter to call the Second job where you would be Accessing the file and extracting releveant columns and putting into the table
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Take a look at the properties of the Folder stage in Manager, or from the Repository view in Designer. There are two "columns". One is the "key" which, from the O/S point of view, is the file name. The other is the "record" which, from the O/S point of view, is the entire file. The second of these is of limited use, though can be parsed within a DataStage job. The Folder stage is really intended for the "see what file names are there" kind of operation.

Ray Wurlod
Education and Consulting Services
ABN 57 092 448 518
mhester
Participant
Posts: 622
Joined: Tue Mar 04, 2003 5:26 am
Location: Phoenix, AZ
Contact:

Post by mhester »

Or moving many files of a certain type (or all) from one directory to another, which is how most customers use this stage.

Regards,

Michael Hester
thirupri
Premium Member
Premium Member
Posts: 40
Joined: Wed Sep 17, 2003 3:41 am
Location: Saudi Arabia
Contact:

Post by thirupri »

Hi,

This is what I did as same as your requirement. First, I created a job using the Folder Stage with output column (1) Docname (filenames) to a sequential file then I transferred this to a hash file in the same Job. Then, I created another Job (Job3), which will accept the File name & File path as a Input parameter. The In a Script I read this Hash file and pass the file name to Job3.

Thiruma Valavan.
Best Regards,
Thiruma Valavan
roy
Participant
Posts: 2598
Joined: Wed Jul 30, 2003 2:05 am
Location: Israel

Post by roy »

Hi,
I want to point out that the folder stage has a file size limit (probably configurable).
It will cause errors, if I'm not mistaken, in cases any file exeeds the limit.
Hence I would prefer to use any DSExecute() flavour via DSRoutine toget the list of file you need, especially if they might be really big ones.
( up to 100 MB is usually fine maybe even more but around 150-200+ MB your in trouble )

IHTH (I Hope This Helps)
Roy R.
Time is money but when you don't have money time is all you can afford.

Search before posting:)

Join the DataStagers team effort at:
http://www.worldcommunitygrid.org
Image
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

DataStage (and therefore DataStage BASIC) has the quirky ability to treat a directory (folder) as a "table". This is the underlying premise of the Folder stage. You can do the same thing in DataStage BASIC. If the O/S directory is seen by DS as a table, then each file name in that directory is seen by DS as a record key, and each file in that directory is seen by DS as a "record" - even though it's unlikely that every record has the same structure.
Use OpenPath to open the directory, Select to generate a list of file names, and ReadNext to process that list. For example:

Code: Select all

$INCLUDE UNIVERSE.INCLUDE FILENAMES.H
OpenPath "/usr3/datastage/hashedfiles" To filevariable
Then
   Clearselect 10
   Select filevariable To 10
   Loop
   While ReadNext FileName From 10
      FilePath = "/usr/datastage/hashedfiles/" : FileName
      Cmd = UV.BIN : UV.FSEP : "clearfile " : FilePath
      Call DSExecute("UV", Cmd, Output, ExitStatus)
      Call DSLogInfo(Output, "MyRoutine")
   Repeat
End
Else
   Msg = "Can not open /usr3/datastage/hashedfiles"
   Call DSLogWarn(Msg, "MyRoutine")
End
Post Reply