# String Manipulation and cleaning data

**URL:** <https://forum.knime.com/t/string-manipulation-and-cleaning-data/84544>\
**Category:** KNIME Analytics Platform\
**Created:** [November 12, 2024, 12:43pm UTC](https://forum.knime.com/t/string-manipulation-and-cleaning-data/84544 "2024-11-12T12:43:59Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![arvindev](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/a/f17d59/32.png) [@arvindev](https://forum.knime.com/u/arvindev)\
**Post date:** [November 12, 2024, 12:43pm UTC](https://forum.knime.com/t/string-manipulation-and-cleaning-data/84544/1 "2024-11-12T12:43:59Z")

</div>

I connect to a csv file and extract a list of first names  
They are not cleaned and have examples like Title in the Firstname Mr or Miss  
or Full stops in them, or they have two names like Steve White, where we want to split them up and put Steve as the first name and White as the last name.  
If the firstname is Mr.Steve then we would want to put Mr in the title field and the update the firstname to Steve.  
I know I can find things with RegEx but need a little bit of help to create the logic to split things up rather than just do one step

---

<div class="post-metadata">

**Author:** ![sanket\_2012](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/s/c2a13f/32.png) [@sanket\_2012](https://forum.knime.com/u/sanket_2012)\
**Post date:** [November 12, 2024, 1:34pm UTC](https://forum.knime.com/t/string-manipulation-and-cleaning-data/84544/2 "2024-11-12T13:34:05Z")

</div>

Hi @arvindev ,  
You might want to try using the [Cell splitter node](https://hub.knime.com/knime/extensions/org.knime.features.base/latest/org.knime.base.node.preproc.cellsplit2.CellSplitter2NodeFactory), you split on “.” and output the string as new columns, and then you can rename those columns using [Column Renamer](https://hub.knime.com/knime/extensions/org.knime.features.base/latest/org.knime.base.node.preproc.column.renamer.ColumnRenamerNodeFactory).

Let us know if it helps.

Thanks,  
Sanket

---

<div class="post-metadata">

**Author:** ![arvindev](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/a/f17d59/32.png) [@arvindev](https://forum.knime.com/u/arvindev)\
**Post date:** [November 12, 2024, 2:23pm UTC](https://forum.knime.com/t/string-manipulation-and-cleaning-data/84544/3 "2024-11-12T14:23:50Z")

</div>

Thanks foy your help! I did as you said and now I get the two fields. What I want to do next is delete any fields thats are less than 1 characters in the first split column.  
And then what I need help with is how do I compare the columns and perform updates on calculated function.  
For example if the Column 1 field is ‘Mr’ then I want to replace it with the Column 2 value.  
I also want to know how I can create a new column called Title if the Firstcolumn has ‘Mr’ or ‘Mrs’ in it and then replace it with the Column 2 value.

 ![image](https://forum-cdn.knime.com/uploads/default/original/3X/5/6/56da09f5b4912083158c83a4233097e1db6f5494.png)

---

<div class="post-metadata">

**Author:** ![elsamuel](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/e/b4bc9f/32.png) [@elsamuel](https://forum.knime.com/u/elsamuel)\
**Post date:** [November 13, 2024, 1:26pm UTC](https://forum.knime.com/t/string-manipulation-and-cleaning-data/84544/4 "2024-11-13T13:26:01Z")

</div>

You’d need to use a column expressions node to calculate the length of the value in a column, then you can filter rows based on thata column.

Use a column expressions or rule engine node for your other comparisons/replacements.

---

<div class="post-metadata">

**Author:** ![arvindev](https://forum-cdn.knime.com/letter_avatar_proxy/v4/letter/a/f17d59/32.png) [@arvindev](https://forum.knime.com/u/arvindev)\
**Post date:** [November 13, 2024, 2:23pm UTC](https://forum.knime.com/t/string-manipulation-and-cleaning-data/84544/5 "2024-11-13T14:23:33Z")

</div>

Where can I find any examples of Column expressions i…e examples of complex use of expression builder?

---

<div class="post-metadata">

**Author:** ![mlauber71](https://forum-cdn.knime.com/user_avatar/forum.knime.com/mlauber71/32/73590_2.png) [@mlauber71](https://forum.knime.com/u/mlauber71)\
**Post date:** [November 13, 2024, 8:15pm UTC](https://forum.knime.com/t/string-manipulation-and-cleaning-data/84544/6 "2024-11-13T20:15:22Z")

</div>

@arvindev here is an example of how to employ a local LLM to sich a split with somewhat unstructured data. Maybe you can adapt the prompt.

> [@Splitting fields with Multiple Values](https://forum.knime.com/t/splitting-fields-with-multiple-values/84090/3):
>
> @TSL4000 welcome to the KNIME Forum. I thought this would be a fun task for KNIME’s LLM nodes and Ollama/Llama3.2. The result after some tweaking of the input and the prompt can look like this: Some lines have not been fully covered … mainly where there are several names but no and or ampersand. One might have to amend the prompt to cover such cases but first: What is happening is that the original content gets converted in a JSOn structure in chunks of 10 and this JSON then gets fed…

---

<div class="post-metadata">

**Author:** ![system](https://forum-cdn.knime.com/uploads/default/original/1X/ab3ccf34482a0329361734a18199390177204f15.png) [@system](https://forum.knime.com/u/system)\
**Post date:** [February 11, 2025, 8:15pm UTC](https://forum.knime.com/t/string-manipulation-and-cleaning-data/84544/7 "2025-02-11T20:15:59Z")

</div>

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