# Read in Strings to vtkTableNode?

**URL:** <https://discourse.slicer.org/t/read-in-strings-to-vtktablenode/44171>\
**Category:** Development\
**Created:** [August 22, 2025, 5:29pm UTC](https://discourse.slicer.org/t/read-in-strings-to-vtktablenode/44171 "2025-08-22T17:29:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrsh0r3s](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/mrsh0r3s/32/80860_2.png) [@mrsh0r3s](https://discourse.slicer.org/u/mrsh0r3s)\
**Post date:** [August 22, 2025, 5:29pm UTC](https://discourse.slicer.org/t/read-in-strings-to-vtktablenode/44171/1 "2025-08-22T17:29:57Z")

</div>

Hello,

Whenever I try to use the slicer.util.updateTableFromArray() function to import an array with a string value - say “DeviceID” - I get the error “ValueError: could not convert string to float: ‘DeviceID’”

Numerical arrays work just fine but string arrays, object arrays, or anything that isn’t exclusively numbers fails. If I pass an array of strings that are numbers - for instance np.array([[‘0’, ‘0’, ‘0’]])which could be seen as the equivalent of np.zeros((1,3)).astype(str) - the table reads it in but still has columns with Data type set to float when examined in Slicer’s Table module.

Is there a better way to import string or mixed tables through code?

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [August 23, 2025, 2:57am UTC](https://discourse.slicer.org/t/read-in-strings-to-vtktablenode/44171/2 "2025-08-23T02:57:49Z")

</div>

`slicer.util.updateTableFromArray()` only works for numeric types (as VTK only offers array mapping for these types). You can set string elements one by one:

```python
column = tableNode.GetTable().GetColumn(0)

column.InsertNextValue("asdf")
column.InsertNextValue("zxcv")
column.InsertNextValue("qwerty")

tableNode.GetTable().Modified()

```
