How to replace single characters in a Excel column using a dictionary of key-value pairs?

Hello everyone.

Introduction

I am trying to replace just some characters inside Excel cells. The reason is a strange encoding or something like that gives me troubles.

I guess the most similar post I have found here in the forum is Finding and replacing part of a string but the solution there is too simple for my needs.

Example

I’ll try to explain what I need showing an example. Some rows of my Excel file are as follow (Italian language):

Row ID String
0 PI√ô
1 CITTÊ

and I’d like to have a table as follows

Row ID String NewString
0 PI√ô PIÙ
1 CITT√ä CITTÀ

What I’ve done

I have tried with the String Replace (Dictionary) node but it’s not working as I would like. I believe this is because the node is looking for whole strings instead of looking for single characters inside strings.

Just to be clear, the dictionary I want to use for these replacements has got 256 rows and many characters should be escaped in the case I’d try a regex.

Hope someone has an idea about how to solve this. Thanks in advance.

1 Like

Hi @fryfella,

welcome to the KNIME community!

I would suggest to use a recursive loop. You can find an example with a small dictionary replacing some special characters in German language on the KNIME Hub:

To get familiar with recursive loops I recommend the following video:

Best
Kathrin

6 Likes

Hi @Kathrin, that worked like a charm!!

Thanks both for your kind welcome and reply :slight_smile:

1 Like

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