
Anonymous
Not applicable
2013-04-26
11:21 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
tmap remove leading zeros from a string
I have a customer table (customer number and custumer name). Most of the custumers are integer, but some of them have a "L" in front of them. The custumer number is therefore type string. The problem is that the "integer" custumers have leading zeros - for instance 0000113934 which I can remove if I make it integer, but thats not possible with the custumers starting with "L" for instance L1993493.
I tried in the tmap to make the expression:
StringHandling.LEFT(row1.Customer_number,1).equals("0")?
StringHandling.STR(Mathematical.INT(row1.Customer_number),50): row1.Customer_number
But then I get the error:
The method STR(char, int) in the type StringHandling is not applicable for the arguments (int, int)
I also tried to filter the custumer numbers starting with zero in tmap and then putting the filtered output through tconverttype to cast it to integer and then another tconverttype to cast it back to string, but then when I use tunite with the other output from tmap where the custumer numbers does not start with zero I cannot get it to connect to the tunite.
Any good ideas?
I tried in the tmap to make the expression:
StringHandling.LEFT(row1.Customer_number,1).equals("0")?
StringHandling.STR(Mathematical.INT(row1.Customer_number),50): row1.Customer_number
But then I get the error:
The method STR(char, int) in the type StringHandling is not applicable for the arguments (int, int)
I also tried to filter the custumer numbers starting with zero in tmap and then putting the filtered output through tconverttype to cast it to integer and then another tconverttype to cast it back to string, but then when I use tunite with the other output from tmap where the custumer numbers does not start with zero I cannot get it to connect to the tunite.
Any good ideas?
648 Views
3 Replies

Creator II
2013-04-26
11:40 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can't unite two outputs from the same tMap.
Have you tried
StringHandling.LEFT(row1.Customer_number,1).equals("0")?
Integer.toString(Integer.parseInt(row1.Customer_number)): row1.Customer_number
Have you tried
StringHandling.LEFT(row1.Customer_number,1).equals("0")?
Integer.toString(Integer.parseInt(row1.Customer_number)): row1.Customer_number
648 Views

Anonymous
Not applicable
2013-04-26
02:47 PM
Author
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks a lot - that works just like intended.
648 Views

Specialist
2013-04-28
08:46 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My 2 cents even though janhess's solution worked for you
: I like regex for these sorts of things as it's usually a neater expression so I would use:
row1.Customer_number.replaceAll("^0*","")
row1.Customer_number.replaceAll("^0*","")
648 Views
