# Changing a sentence to CamelCase

**URL:** <https://forum.dynamobim.com/t/changing-a-sentence-to-camelcase/61047>\
**Category:** Lists-Logic\
**Tags:** share\
**Created:** [March 1, 2021, 3:25pm UTC](https://forum.dynamobim.com/t/changing-a-sentence-to-camelcase/61047 "2021-03-01T15:25:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![JoziB](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@JoziB](https://forum.dynamobim.com/u/JoziB)\
**Post date:** [March 1, 2021, 3:25pm UTC](https://forum.dynamobim.com/t/changing-a-sentence-to-camelcase/61047/1 "2021-03-01T15:25:21Z")

</div>

I recently had to change some text to CamelCase, I searched the forums and while there are discussion on it, I couldn’t come to a solution. I found a Python method, one using an old package called Zebra, the later gave some issues with obsolete packages.

Anyhow, long story short, the below is what I ended up with and I thought it might be of some use to others searching how to do this. I have no doubt it can be improved on, there probably is a package or node I didn’t find but it seems to work.

 ![ChangeToCamelCase](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/c/6/c68bc3da6c4633acea4000625fee44a90593a7af.png)

…and as I just exported the above image, I spot on issue where I’m converting everything to lowercase, incl a CamelCase word.

---

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [March 1, 2021, 6:18pm UTC](https://forum.dynamobim.com/t/changing-a-sentence-to-camelcase/61047/2 "2021-03-01T18:18:10Z")

</div>

Hello  
a solution with Python (using the same logic)

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/2/22fc8a4f31377ea97f881287d001ef359d122cb5.png)

```
var = "text to convert to CamelCase"
OUT = ''.join(x[0].upper() + x[1:] for x in var.split(' '))
```

---

<div class="post-metadata">

**Author:** ![JoziB](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@JoziB](https://forum.dynamobim.com/u/JoziB)\
**Post date:** [March 1, 2021, 6:25pm UTC](https://forum.dynamobim.com/t/changing-a-sentence-to-camelcase/61047/3 "2021-03-01T18:25:17Z")

</div>

I found some python code to do it but it never worked for me

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/f/e/fe041c8c5fd91257c27c1e60ed914bee3ee2b1e6.jpeg)

“OUT = map(str.title, IN[0])”;

How do I get your code to work so it converts an input from a string?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/9/d9fe4f5cd858ddf9450f09d0087dfa9a98601e0f.jpeg)

---

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [March 1, 2021, 6:28pm UTC](https://forum.dynamobim.com/t/changing-a-sentence-to-camelcase/61047/4 "2021-03-01T18:28:29Z")

</div>

> [@JoziB](#):
>
> How do I get your code to work so it converts an input from a string?

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/d/3/d339fb83a61f1d4e39a4f8aab356d6da348a3195.png)  
//  
`OUT = ''.join(x[0].upper() + x[1:] for x in IN[0].split(' '))`

---

<div class="post-metadata">

**Author:** ![AmolShah](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/amolshah/32/103244_2.png) [@AmolShah](https://forum.dynamobim.com/u/AmolShah)\
**Post date:** [March 1, 2021, 6:31pm UTC](https://forum.dynamobim.com/t/changing-a-sentence-to-camelcase/61047/5 "2021-03-01T18:31:28Z")

</div>

@JoziB Nodes from Rhythm & Designtech package can help as well!  
 ![Capture](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/b/8/b877d582d844df331ac1b317ba3050b887c35489.png)

---

<div class="post-metadata">

**Author:** ![JoziB](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@JoziB](https://forum.dynamobim.com/u/JoziB)\
**Post date:** [March 1, 2021, 6:55pm UTC](https://forum.dynamobim.com/t/changing-a-sentence-to-camelcase/61047/6 "2021-03-01T18:55:01Z")

</div>

I’m not able to get that to work. I had a problem earlier with Data-Shapes and (I think) the input being a list rather than a string, this looks to be the same.

 ![image](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/e/f/ef747a7f4e4ff84423dfaaf872ec9afe0dc8e8cd.jpeg)

@AmolShah  
I have Rythem but I must be on an older version which doesn’t have that node. And un-aware of the designtech package! I’ll download/update my packages!

---

<div class="post-metadata">

**Author:** ![c.poupin](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/c.poupin/32/89152_2.png) [@c.poupin](https://forum.dynamobim.com/u/c.poupin)\
**Post date:** [March 1, 2021, 7:41pm UTC](https://forum.dynamobim.com/t/changing-a-sentence-to-camelcase/61047/7 "2021-03-01T19:41:50Z")

</div>

> [@JoziB](#):
>
> I’m not able to get that to work. I had a problem earlier with Data-Shapes and (I think) the input being a list rather than a string, this looks to be the same.

try this if you want a string at the output

```
import clr
import sys

toSingle = lambda x : x[0] if isinstance(x, list) else x
input = toSingle(IN[0])
OUT = ''.join(x[0].upper() + x[1:] for x in input.split(' '))

```

**or** if you want a list at the output

```
import clr
import sys

toList = lambda x : x if isinstance(x, list) else [x]
inputLst = toList(IN[0])
out = []
for lst in inputLst:
	out.append(''.join(x[0].upper() + x[1:] for x in lst.split(' ')))

OUT = out

```

---

<div class="post-metadata">

**Author:** ![JoziB](https://avatars.discourse-cdn.com/v4/letter/j/9fc29f/32.png) [@JoziB](https://forum.dynamobim.com/u/JoziB)\
**Post date:** [March 3, 2021, 5:45pm UTC](https://forum.dynamobim.com/t/changing-a-sentence-to-camelcase/61047/8 "2021-03-03T17:45:27Z")

</div>

Thanks, both of those worked for me in the script! I was able to cut out everything in my first post 😂
