Reading a .ini file

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
Django
Premium Member
Premium Member
Posts: 20
Joined: Fri Apr 18, 2008 12:16 am

Reading a .ini file

Post by Django »

Hello DS Djangos

I'm sure I'll get the desired help here.

I have got multiple .ini files sitting in the inbox folder. The format of the .ini files are

Code: Select all


[Section]
Subject=Value

Eg.
[History Loading]
ServerList=localhost1,localhost2,localhost3

[localhost1]
Name=Brad
Address=2 Winging 

[localhost2]
Name=Pitt
Address=3 Crazy 

The following I need in the output which is a single dataset file for all .ini file inputs. It has 4 columns

------------------------------------------------------------------------------
ini_FileName   ServerList                                  Name       Address
----------------------------------------------------------------------------
apsv002.ini     localhost1,localhost2,localhost3         Brad      2 Winging 
apsv002.ini     localhost1,localhost2,localhost3         Pitt      3 Crazy 
apsv002.ini     localhost1,localhost2,localhost3         Pock      4 Notsocrazy 

apsv003.ini     localhost1                               Mock      2 Magenta

apsv004.ini     localhost1, localhost2                   Tock      14 Scar
apsv005.ini     localhost1, localhost2                   Jack      24 Huges
      
Please let me know if there is a workaround to read ini file. Or I have to write a new datastage .ini reader ??? :cry:

As for getting the file name I used the pattern *.ini in the datastage sequential stage and used the FileName=ini_FileName column property. When I run the Job the ini_FileName output column contains *.ini instead of the individual file name that I was expecting.

Any light ?
Django
If a simple dsx project requires such intelligence how much more is required to create this Cosmic System. Who dares to say there is no intelligence behind this creation i.e. no GOD .....
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

Welcome aboard.

In a Transformer stage keep track of the most recently encountered section (use a stage variable) and direct any non-section line to the appropriate column of the output.

Use an output constraint to avoid processing empty and comment lines.

Use the File Name property (which the Sequential File stage provides) to provide the file name - you may need to parse this out of a pathname using Field() and Count() functions.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply