Dear all,
I want to rename columns if they have specific names. For that I am using the columnExists function in a Java snippet. It works fine, but now I would like to rename the existing columns by adding some prefix. Is that possible?
I know that its much easier with R or Python but I have sdf/smiles columns which are converted to string if I use such snippets. This will make my life harder as I would have to change the overall workflow (as the molecule column name changes), whereas with java this could be done within one node.
If there are other options to do this in a dynamic way I’ll also be glad to get to know these.
thanks. Unfortunately this is not possible. I do not want to append the suffix to all columns, only the ones which have problematic names. And as the names are non-related I cannot generate a useful Regex to match all of the names.
What I want to do:
0. Load a file chosen by user
Find out if I have columns with specific names, eg x = [ SMILES,Prop1,Name]
If a column is named as in x : Append suffix given by user in Quickform
–> If no column is named: proceed
In python this is straightforward but it does convert Molecule formats to strings, which would need me to know the molecules columns name and convert it back to the respective format. It is doable, but it would be easier if I could just change the names without converting the mol column to string (and therefore the need to know what the Molecule format and column name is).
P.S. If you really want to use a Java Snippet node to do the renaming, you can try a similar approach, but it’s a bit more complex/inelegant, IMHO. Replace the col rename node with Java Snippet and use a flow variable to dynamically rename the column using the flow variable tab similar to the second pic above.