Use of index function
Moderators: chulett, rschirm, roy
Use of index function
Hi all,
I am not getting the proper output while using index function.
My source data contains data like this
-------------------------
file_name,file_type
abcd.txt,txt
efgh.csv,csv
--------------------------
I want the output like this
------------------------------
file_name,file_type,occurence
abcd.txt,txt,5
efgh.csv,csv,5
------------------------------------
the value of occurence is calculated by calaculating the the position of " . " in the file_name column
for this I have used a stage variable whose derivation is set to
index(input.file_name,'.',1)and mapped to the occurence column.
But every time I am getting the value as 0.
Can anybody suggest?
I am not getting the proper output while using index function.
My source data contains data like this
-------------------------
file_name,file_type
abcd.txt,txt
efgh.csv,csv
--------------------------
I want the output like this
------------------------------
file_name,file_type,occurence
abcd.txt,txt,5
efgh.csv,csv,5
------------------------------------
the value of occurence is calculated by calaculating the the position of " . " in the file_name column
for this I have used a stage variable whose derivation is set to
index(input.file_name,'.',1)and mapped to the occurence column.
But every time I am getting the value as 0.
Can anybody suggest?
Is your job parallel or server?
0 means it is not finding "." in the input string.
For server job, try writing small subroutine and check like
findDot
call the subroutine in column derivation of occurance as findDot(file_name), though ur code and this routine are same, just for checking.
0 means it is not finding "." in the input string.
For server job, try writing small subroutine and check like
findDot
Code: Select all
Position = Index(Arg1, ".", 1)
Ans = Position
-
- Participant
- Posts: 612
- Joined: Thu May 03, 2007 4:59 am
- Location: Melbourne
index(input.file_name,'.',1) or index(input.file_name,".",1) is right. Stage variable type also does not matter even if you are using the default type. Now you need to debug yourself with different sample records.
Last edited by JoshGeorge on Mon May 28, 2007 7:00 am, edited 1 time in total.
Joshy George
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
<a href="http://www.linkedin.com/in/joshygeorge1" ><img src="http://www.linkedin.com/img/webpromo/bt ... _80x15.gif" width="80" height="15" border="0"></a>
josh,
I have put the same syntax on the top what you have specified,but I am getting 0 as output.
I have used the stage varibale like this
input.filename stagevar1
index(stagevar1,'.',1) stagevar2
The data type I have specified as varchar for both the stage variables,I tried with specifying integer also but nt able to get the output as required.
I have put the same syntax on the top what you have specified,but I am getting 0 as output.
I have used the stage varibale like this
input.filename stagevar1
index(stagevar1,'.',1) stagevar2
The data type I have specified as varchar for both the stage variables,I tried with specifying integer also but nt able to get the output as required.
Have column datatype as varchar in row generator. Have a test job with only one column and generate value for that column alone.
Also, Try writing the sequential file to peek to check what you receive is what you expect.
Do you get any warnings when you run the job?
Were you able to view data in the sequential file?
Also, Try writing the sequential file to peek to check what you receive is what you expect.
Do you get any warnings when you run the job?
Were you able to view data in the sequential file?
Then there is something fishy in the data.
Try the following and see what the following shows in your output
Try the following and see what the following shows in your output
Code: Select all
Field(in.Data, ".", 1)
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
-
- 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: