Encoding customer number

Hi,

i am looking for a node to encode customer numbers:

example:
Customer number oringinal:
1234567890

Customer number encoded: Logic:(1=2; 2=3; 3=4;4=5;5=6;7=8;8=9;9=0;0=1)
2345678901

Hope someone could help me. Thanks regards Chris

Hi Chris,

I would take a Java Snippet with (quick & dirty)…

int i = 1234567890;
String is = Integer.toString(i);
ArrayList a = new ArrayList<>(10);
a.add(β€œ1”);
a.add(β€œ2”);
a.add(β€œ3”);
a.add(β€œ4”);
a.add(β€œ5”);
a.add(β€œ6”);
a.add(β€œ7”);
a.add(β€œ8”);
a.add(β€œ9”);
ArrayList b = new ArrayList<>(10);
b.add(β€œ1”);
b.add(β€œ2”);
b.add(β€œ3”);
b.add(β€œ4”);
b.add(β€œ5”);
b.add(β€œ6”);
b.add(β€œ7”);
b.add(β€œ8”);
b.add(β€œ9”);
b.add(β€œ0”);
String js = β€œβ€;
for(int n=0;n<is.length();n++) {
js += b.get(a.indexOf(is.substring(n, n+1)));
}

Input would be a String, then start with β€œis” above, or an Integer, then β€œi”.
Output js as a String.

Greetz, Tommy

1 Like

Hi there @Chris87 ,

I would go scripting as well in this case - Java, Python or JavaScript. Everything else seems too complicated…

Br,
Ivan

1 Like

Hi @ipazin , @Chris87

Maybe it is to complicated … :upside_down_face: but possible encoding_custom_nr.knwf (54.4 KB)


gr. Hans

2 Likes

Hi,

Nice one @HansS but would take different approach. After Cell Splitter go with transpose node and Cell Replacer which will actually do the encoding. Then transpose and combine columns back. And of course there is one loop iteration per row :smiley:

Br,
Ivan

1 Like

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