# QuerySelect by string value

**URL:** https://discourse.paraview.org/t/queryselect-by-string-value/10025
**Category:** ParaView Support
**Tags:** python
**Created:** [July 19, 2022, 8:30am UTC](https://discourse.paraview.org/t/queryselect-by-string-value/10025 "2022-07-19T08:30:58Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Denys](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/d/9de0a6/32.png) [@Denys](https://discourse.paraview.org/u/Denys)
#### Post date: [July 19, 2022, 8:30am UTC](https://discourse.paraview.org/t/queryselect-by-string-value/10025/1 "2022-07-19T08:30:58Z")

</div>

Hi, I have an issue while selecting Cells by string array value.  
This is my query:

```auto
QuerySelect(QueryString='(Name == 3_S_8_qwerty-0_ytrewq7)&(Type == SomeType)', FieldType='CELL', InsideOut=0)

```

and this is an error I’m getting as a result:

```auto
    Name == 3_S_8_room-0_wall7
             ^
SyntaxError: invalid decimal literal

```

Obviously it takes my string value as a number, due to leading decimal. Also, in case I put underscore in front of the string `_3_S_8_qwerty-0_ytrewq7` it will give me the same error but related to the text after `minus` char.

So the question is: are there any ways to set that string as a value to compare to (without changing/encoding/normalizing the `Name` values as input)?

PS: quotes didn’t help.  
PPS: i know that it supports `numpy` features. Maybe there is something I’ve missed regarding strings comparison?

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [July 19, 2022, 11:36am UTC](https://discourse.paraview.org/t/queryselect-by-string-value/10025/2 "2022-07-19T11:36:49Z")

</div>

```auto
"3_S_8_qwerty-0_ytrewq7"

```

maybe ?

---

<div class="post-metadata">

### Author: ![Denys](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/d/9de0a6/32.png) [@Denys](https://discourse.paraview.org/u/Denys)
#### Post date: [July 19, 2022, 12:03pm UTC](https://discourse.paraview.org/t/queryselect-by-string-value/10025/3 "2022-07-19T12:03:43Z")

</div>

As I’ve mentioned in PS, quotes didn’t work: error was gone, but result was wrong (nothing was found/selected).

---

<div class="post-metadata">

### Author: ![mwestphal](https://discourse.paraview.org/user_avatar/discourse.paraview.org/mwestphal/32/17_2.png) [@mwestphal](https://discourse.paraview.org/u/mwestphal)
#### Post date: [July 19, 2022, 12:06pm UTC](https://discourse.paraview.org/t/queryselect-by-string-value/10025/4 "2022-07-19T12:06:44Z")

</div>

Can you share your data ?

---

<div class="post-metadata">

### Author: ![Denys](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/d/9de0a6/32.png) [@Denys](https://discourse.paraview.org/u/Denys)
#### Post date: [July 19, 2022, 2:01pm UTC](https://discourse.paraview.org/t/queryselect-by-string-value/10025/5 "2022-07-19T14:01:17Z")

</div>

Sorry, I’m not allowed to share it here. But I can describe how it is being generated.

CellData is extended on import by manually added String arrays. `Name` array is added along with them.  
Input is a vtp, where each piece has some metadata added along with tag:  
`<Piece Name="3_S_8_qwerty-0_ytrewq7">`

We parse the file with `vtkXMLPolyDataReader` and generate a MultiblockDataSet as our custom reader’s output. Along with copying every piece to a separate block, we read metadata from the same file using `xml.etree.ElementTree`. The metadata values are added as a separate vtkStringArray to the block’s CellData.

PS: Hope I didn’t describe it too complicated.  
PPS: maybe there is a better way to get attributes per piece from `vtkXMLPolyDataReader` directly.

---

<div class="post-metadata">

### Author: ![Andrew\_Maclean](https://discourse.paraview.org/letter_avatar_proxy/v4/letter/a/e56c9b/32.png) [@Andrew\_Maclean](https://discourse.paraview.org/u/Andrew_Maclean)
#### Post date: [July 20, 2022, 12:46am UTC](https://discourse.paraview.org/t/queryselect-by-string-value/10025/6 "2022-07-20T00:46:31Z")

</div>

I suspect that you are seeing underscore grouping [PEP 515 – Underscores in Numeric Literals | peps.python.org](https://peps.python.org/pep-0515/). It is probably seeing the underscore after the digit as a grouping for numeric values so it’s treating the string as numeric hence the error. Escaping the underscore might fix it.

Try “3\_S\_8\_qwerty-0\_ytrewq7”
