# Issue manipulating string read from a feeder

**URL:** <https://community.gatling.io/t/issue-manipulating-string-read-from-a-feeder/4493>\
**Category:** Gatling (Open-Source)\
**Created:** [September 10, 2018, 5:18pm UTC](https://community.gatling.io/t/issue-manipulating-string-read-from-a-feeder/4493 "2018-09-10T17:18:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![sv1](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@sv1](https://community.gatling.io/u/sv1)\
**Post date:** [September 10, 2018, 5:18pm UTC](https://community.gatling.io/t/issue-manipulating-string-read-from-a-feeder/4493/1 "2018-09-10T17:18:40Z")

</div>

Hi,

I found a problem with scala + gatling combination, and after a lot of research, looks like gatling feeder does not pass the value correctly reading from CSV to the session, especially when you do a string manipulation ( using split() in my case). I do not think there is a logical problem with my code, since the same thing works, if i hardcode the values, but does not split when i read from csv.

Simulation Class:

```auto
class DPerfTest extends Simulation {

    setUp(  
      DScenario.checkKIE
        .inject(constantUsersPerSec(RequestHelper.keepItUsers) during (RequestHelper.keepItDuration))

    ).protocols(RequestHelper.httpRequest)
}

```

```auto

```

```auto
Scenario:

```

---

<div class="post-metadata">

**Author:** ![sv1](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@sv1](https://community.gatling.io/u/sv1)\
**Post date:** [September 10, 2018, 6:40pm UTC](https://community.gatling.io/t/issue-manipulating-string-read-from-a-feeder/4493/2 "2018-09-10T18:40:38Z")

</div>

Versions:

```auto
<gatling-plugin.version>2.2.4</gatling-plugin.version>
<gatling.version>2.3.0</gatling.version>
<mssql.jdbc.version>6.1.0.jre8</mssql.jdbc.version>
<scala-maven-plugin.version>3.2.2</scala-maven-plugin.version>

```

---

<div class="post-metadata">

**Author:** ![sv1](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@sv1](https://community.gatling.io/u/sv1)\
**Post date:** [September 10, 2018, 6:43pm UTC](https://community.gatling.io/t/issue-manipulating-string-read-from-a-feeder/4493/3 "2018-09-10T18:43:48Z")

</div>

Same with updated version

```auto
<gatling.version>2.3.1</gatling.version>
<gatling-plugin.version>2.2.4</gatling-plugin.version>
<scala-maven-plugin.version>3.4.2</scala-maven-plugin.version>

```

---

<div class="post-metadata">

**Author:** ![sv1](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@sv1](https://community.gatling.io/u/sv1)\
**Post date:** [September 14, 2018, 1:28pm UTC](https://community.gatling.io/t/issue-manipulating-string-read-from-a-feeder/4493/4 "2018-09-14T13:28:24Z")

</div>

Hi,

Can someone please help? It looks like a bug to me in gatling, did anyone else have a similar experience? If so how did you fix it?

---

<div class="post-metadata">

**Author:** ![Marc\_Holden](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@Marc\_Holden](https://community.gatling.io/u/Marc_Holden)\
**Post date:** [September 14, 2018, 2:10pm UTC](https://community.gatling.io/t/issue-manipulating-string-read-from-a-feeder/4493/5 "2018-09-14T14:10:33Z")

</div>

Try removing the ‘s’ before the opening triple quote. See here for details.

[https://docs.scala-lang.org/overviews/core/string-interpolation.htmln](https://docs.scala-lang.org/overviews/core/string-interpolation.htmln)

---

<div class="post-metadata">

**Author:** ![slandelle](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/slandelle/32/4_2.png) [@slandelle](https://community.gatling.io/u/slandelle)\
**Post date:** [September 14, 2018, 2:13pm UTC](https://community.gatling.io/t/issue-manipulating-string-read-from-a-feeder/4493/6 "2018-09-14T14:13:42Z")

</div>

> RequestBody.itemDetailRequest(“${u}”, “${i}”, “${a}”, “${ii}”))

This is not a Gatling issue, you can’t pass some Gatling EL String to your own code and expect replacement to magically happen.  
From [https://gatling.io/docs/current/session/expression\_el/#expression-language](https://gatling.io/docs/current/session/expression_el/#expression-language):

Warning

This Expression Language only works on the final value that is passed to the DSL method when the Simulation is instantiated.

For example, `queryParam("latitude", "${latitude}".toInt + 24)` won’t work, the program will blow on `"${latitude}".toInt` as this String can’t be parsed into an Int.

The solution here would be to pass a function:

`session => session("latitude").validate[Int].map(i => i + 24)`.

---

<div class="post-metadata">

**Author:** ![sv1](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@sv1](https://community.gatling.io/u/sv1)\
**Post date:** [September 17, 2018, 1:19pm UTC](https://community.gatling.io/t/issue-manipulating-string-read-from-a-feeder/4493/7 "2018-09-17T13:19:56Z")

</div>

Hi Stephene,  
Thanks for pointing out to that link. I did read that document again today, but it still seems impossible to get the string to split in my scenarioIf I use exec(POST), I do not have access to the session. If I use exec(session), my POST does not work.( UnsupportedOperationException: There were no requests sent during the simulation, reports won’t be generated)

Can you please provide an example as to how to use validate() in this case? Most examples on stackoverflow and here, manipulate the string in the response. I have not come across a working solution where someone was successful in manipulating string read from the feeder. Thanks for your time!

My solution, which fails to compile or which cannot do a POST

```auto
.exec{ session =>
if (session.contains("u")) {
  val u = session("u").toString.split(":").get(0)

```

```auto
 RequestBody.itemDetailRequest(u, "${i}", "${a}", "${ii}"))

```

```auto

```

---

<div class="post-metadata">

**Author:** ![sv1](https://avatars.discourse-cdn.com/v4/letter/s/e99b99/32.png) [@sv1](https://community.gatling.io/u/sv1)\
**Post date:** [September 24, 2018, 6:12pm UTC](https://community.gatling.io/t/issue-manipulating-string-read-from-a-feeder/4493/8 "2018-09-24T18:12:11Z")

</div>

I tried a few more things too, but i am still unable to solve this problem. Can help is greatly appreciated.
