Adding preceding zeros only for number values

Dear Forum,

greetings!
I am struggling with following case and I wonder if someone could help me to figure out the correct coding for this.

In the column expression node I’d like to define that only for numbers in the material column (which currently have a string format from the download), depending on the length, as much zeros are being adding in front so that the total digits equal to 18 digits.
For example:
Material (4 digits originally) -> 18 digits including preceding zeros
4303 -> should be converted to 000000000000004303
1330303 -> 000000000001330303

Below I’ve added an extract of the original data

Sample_data.XLSX (20.4 KB)

Thanking you very much in advance!

Best regards,
Tobias

Hi @Toby76

KNIME_project1.knwf (6.2 KB)

Best regards
Mehrdad

7 Likes

@mehrdad_bgh,

Hello!

My sincere thanks a lot for your great help! Exactly what I needed!

Best regards,
Tobias

3 Likes

Hello there!

there is also padLeft() function for this cases :wink:

Br,
Ivan

2 Likes

Hello ipazin,
thanks a lot for your hint. As I am not familiar with the coding by using padleft, would you mind sharing the coding structure if using this function?

Highly appreciated!
Best regards,
Tobias

Hello @Toby76,

function is available in String Manipulation and Column Expressions nodes. When you click on it you’ll see description together with examples on the left and it should all be clear :wink:

Br,
Ivan

2 Likes

Hi Ivan, thank you~!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.