problem in transversing the file
Moderators: chulett, rschirm, roy
problem in transversing the file
Hi all,
I have requirement like this
I have the DSParam file in the projects folder of the datastage.
I have to get the parametervalue for a particular parameter.
I am struck with transversing the file.
The file looks like
It contains many line arranged irregularly.
and the last it has parametersyntax like this
"paramname"\1\"paramvalue
i am attaching a sample file that i am reading
***************
[functions]
Abs\1\Absolute value of any numeric expression\Mathematical\int32\int32:number\abs
.
.
[serveronly-functions]
Ascii\1\EBCDIC to ASCII string conversion\Conversion\\:string
[parallelonly-functions]
AlNum\1\Return whether the given string consists of alphanumeric characters\String\int8\anystring:string\is_alnum,u_is_alnum
.
.
.
[EnvVarDefns]
ARCHIVE_DIR\User Defined\-1\String\\0\Project\ARCHIVE_DIR\
.
.
..
[EnvVarValues]
"ARCHIVE_DIR"\1\"archive"
"xxxx"\1\"zzzz"
*******
i have traversed to the line where it is equal to " [EnvVarValues]"
After that i have to traverse further and check if the param name is "xxx"
ihave to get the its value that is ZZZ
I am struct up after getting the line as "[EnvVarValues]" how to move further
i have attached the code for looping that i have used
*********
OpenSeq ParamFile To ParamFileVar
On Error
Msg = 'Error opening parameters file, ' : SQuote(ParamFile ): ', status = ' : Status()
Call DSLogFatal(Msg, TransformName )
Abort
End
Else
Msg = 'Cannot open parameters file, ' : SQuote(ParamFile ): ', status = ' : Status()
Call DSLogFatal(Msg, TransformName )
Abort
End
Loop
While ReadSeq Line From ParamFileVar
If Trim(Line)="[EnvVarValues]" Then
Field( Trim(Line),"/",1,1)= ParamName
ParamValue = Field(Trim(Line),"/",1,2)
Repeat
********
Advice me on this
I have requirement like this
I have the DSParam file in the projects folder of the datastage.
I have to get the parametervalue for a particular parameter.
I am struck with transversing the file.
The file looks like
It contains many line arranged irregularly.
and the last it has parametersyntax like this
"paramname"\1\"paramvalue
i am attaching a sample file that i am reading
***************
[functions]
Abs\1\Absolute value of any numeric expression\Mathematical\int32\int32:number\abs
.
.
[serveronly-functions]
Ascii\1\EBCDIC to ASCII string conversion\Conversion\\:string
[parallelonly-functions]
AlNum\1\Return whether the given string consists of alphanumeric characters\String\int8\anystring:string\is_alnum,u_is_alnum
.
.
.
[EnvVarDefns]
ARCHIVE_DIR\User Defined\-1\String\\0\Project\ARCHIVE_DIR\
.
.
..
[EnvVarValues]
"ARCHIVE_DIR"\1\"archive"
"xxxx"\1\"zzzz"
*******
i have traversed to the line where it is equal to " [EnvVarValues]"
After that i have to traverse further and check if the param name is "xxx"
ihave to get the its value that is ZZZ
I am struct up after getting the line as "[EnvVarValues]" how to move further
i have attached the code for looping that i have used
*********
OpenSeq ParamFile To ParamFileVar
On Error
Msg = 'Error opening parameters file, ' : SQuote(ParamFile ): ', status = ' : Status()
Call DSLogFatal(Msg, TransformName )
Abort
End
Else
Msg = 'Cannot open parameters file, ' : SQuote(ParamFile ): ', status = ' : Status()
Call DSLogFatal(Msg, TransformName )
Abort
End
Loop
While ReadSeq Line From ParamFileVar
If Trim(Line)="[EnvVarValues]" Then
Field( Trim(Line),"/",1,1)= ParamName
ParamValue = Field(Trim(Line),"/",1,2)
Repeat
********
Advice me on this
I would use a variable to store the current section, or "state" while reading the file.
Then you can put an IF-THEN construct in to check the lines if you are in the section "EnvVarValues"
Code: Select all
Line = TRIM(Line)
IF Line[1,1]='[' THEN Section = Line[2,LEN(Line)-2]
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
The DataStage read of sequential files is pretty efficient; and DSParams is small file (if the file had millions of records I might reconsider, but this is going to take milliseconds to process).
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
Thanks for the clarification ArndW.ArndW wrote:The DataStage read of sequential files is pretty efficient; and DSParams is small file (if the file had millions of records I might reconsider, but this is going to take milliseconds to process).
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ArndW wrote:I would use a variable to store the current section, or "state" while reading the file.
Code: Select all
Line = TRIM(Line) IF Line[1,1]='[' THEN Section = Line[2,LEN(Line ...[/quote] can you please expand the the code a bit further. I could get a little bit of it
Parvathi, that overall response is a premium one, since I felt it contained something somewhat more complex than just reading in a manual. As mentioned elsewhere, the premium membership makes that post and many more (and more informative) posts visible and accessible to you.
But the important part was visible to you (there isn't much more to my post, anyway). First of all, trim your input string just ONCE. Then use a variable to store which section of the DSParam file you are currently in.
But the important part was visible to you (there isn't much more to my post, anyway). First of all, trim your input string just ONCE. Then use a variable to store which section of the DSParam file you are currently in.
<a href=http://www.worldcommunitygrid.org/team/ ... TZ9H4CGVP1 target="WCGWin">
</a>
</a>
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Code: Select all
Call DSExecute("UNIX", "echo $MyVariable", Result, ExitStatus)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Please correct if I am wrong.ray.wurlod wrote:...Code: Select all
Call DSExecute("UNIX", "echo $MyVariable", Result, ExitStatus)
I have executed the command given above. iam not able to echo the value.
Since my os is unix. I am echoing the value from my user id. where as the variable value that i want is set In DSParams file.
In this file the variable is not assigned
it is given as below.
"paramname"\1"paramvalue"
Can i echo a variable which is given like this.?
Another thing that i have seen is when a variable is set in my .Profileh.
I am able to echoonly those varaibles.
I just wanted to know what ever the varibales that are defined in the adiminstrator are only written to the DSParams file?
When i triiger my master sequencer what is the process flow of the varibles that i am using in the sequencer
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Can you verify that the environment variables are picked up when the job is run? There is a logged event (second in the job run) showing all the environment variables that are used.
In the interim, rather than using an echo command you could use a grep command.
Then parse out the environment variable's value (use the Field() function).
In the interim, rather than using an echo command you could use a grep command.
Code: Select all
Call DSExecute("UNIX", "grep MyVariable DSParams", Result, ExitStatus)
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Doing it at the unix level was my initial thought as well. But since the OP had already started it doing with a BASIC program, I did not say much earlier.
About your second query, what exactly do you mean? Whatever parameters you define in your Master Sequence Job, they will be assigned to other sub sequences and jobs. It will flow down. Is that what your asking?
About your second query, what exactly do you mean? Whatever parameters you define in your Master Sequence Job, they will be assigned to other sub sequences and jobs. It will flow down. Is that what your asking?
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
You have executed this where? Anything declared via the Administrator will be available when jobs are run. If you are 'Test'ing it via a routine or 'executing' this in some other fashion...parvathi wrote:I have executed the command given above. iam not able to echo the value.
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers