Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
package routines;
public class Forum6748Routine {
static java.util.Map<String, String> map = new java.util.HashMap<String, String>();
public static String getCol2Value(String col2) {
String value = null;
String[] array = col2.split(",");
for (int i = 0; i < array.length; i++) {
String item = array;
if ((String) map.get(item) == null) {
value = item;
map.put(item, item);
break;
}
}
return value;
}
}
Starting job forum6748 at 20:25 25/05/2009.
.-----+--------+----.
| tLogRow_1 |
|=----+--------+---=|
|rowID|col1 |col2|
|=----+--------+---=|
|row1 |blue |1 |
|row2 |green |2 |
|row3 |black |3 |
|row4 |white |4 |
|row5 |red |5 |
|row6 |butter |6 |
|row7 |charcoal|7 |
|row8 |clay |8 |
|row9 |yellow |9 |
'-----+--------+----'
Job forum6748 ended at 20:25 25/05/2009.
Hello Xavier
You need to write some java code to finish your request. Here is my example:
Go to Repository-->Code-->and click on the Routine, select 'create routine' option, create a new routine:package routines;
public class Forum6748Routine {
static java.util.Map<String, String> map = new java.util.HashMap<String, String>();
public static String getCol2Value(String col2) {
String value = null;
String[] array = col2.split(",");
for (int i = 0; i < array.length; i++) {
String item = array;
if ((String) map.get(item) == null) {
value = item;
map.put(item, item);
break;
}
}
return value;
}
}
test.csv:
row1;blue,green;1,2
row2;black,white,red;3,4,5
row3;butter,charcoal,clay,yellow;6,7,8,9
result:Starting job forum6748 at 20:25 25/05/2009.
.-----+--------+----.
| tLogRow_1 |
|=----+--------+---=|
|rowID|col1 |col2|
|=----+--------+---=|
|row1 |blue |1 |
|row2 |green |2 |
|row3 |black |3 |
|row4 |white |4 |
|row5 |red |5 |
|row6 |butter |6 |
|row7 |charcoal|7 |
|row8 |clay |8 |
|row9 |yellow |9 |
'-----+--------+----'
Job forum6748 ended at 20:25 25/05/2009.
Let me know if you have any questions!
Best regards
shong