# Unable to increment value from a csv file (looping)

**URL:** <https://community.gatling.io/t/unable-to-increment-value-from-a-csv-file-looping/2434>\
**Category:** Gatling (Open-Source)\
**Created:** [August 3, 2015, 8:48am UTC](https://community.gatling.io/t/unable-to-increment-value-from-a-csv-file-looping/2434 "2015-08-03T08:48:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julian1](https://avatars.discourse-cdn.com/v4/letter/j/258eb7/32.png) [@Julian1](https://community.gatling.io/u/Julian1)\
**Post date:** [August 3, 2015, 8:48am UTC](https://community.gatling.io/t/unable-to-increment-value-from-a-csv-file-looping/2434/1 "2015-08-03T08:48:01Z")

</div>

Hi,

I’m trying to loop the log in step in my scenario with several users (which are stored in a csv file). Feeder works fine. I put “repeat” action for looping and increment to get values in sequence [user1, user2, …, user(n)], but only the first value is being returned.

My script goes like this:

val userCredentials = csv(“user.csv”).circular

val userIdFeeder = Iterator.from(0).map(i =\> Map(“email” → i))  
val iterations = 1;

val scn = scenario(“LoadTest”)

.feed(userIdFeeder)  
.repeat(iterations, “index”){  
exec(session =\> {  
val userIdFeeder = session(“userIdFeeder”).as[Int]  
val index = session(“index”).as[Int]  
val email = iterations \* userIdFeeder + index  
session.set("${email}", “email”)  
println("SESSION: " + session)  
session  
})

.feed(userCredentials)  
.exec(http(“EnterCredentials”)  
.post(uri1 + “/login.do”)  
.headers(headers\_2)  
.formParam(“location”, " ")  
.formParam(“email”, “${email}”)  
.formParam(“password”, “${password}”))  
//.pause(13)  
}

Thanks in advance for your help.

---

<div class="post-metadata">

**Author:** ![notdryft](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/notdryft/32/1103_2.png) [@notdryft](https://community.gatling.io/u/notdryft)\
**Post date:** [August 4, 2015, 11:39am UTC](https://community.gatling.io/t/unable-to-increment-value-from-a-csv-file-looping/2434/2 "2015-08-04T11:39:40Z")

</div>

Hi,

Two things here:

- A new element is extracted from a feeder only once per user, so it is normal that you get the same “userIdFeeder” for each step inside the repeat
- The session is immutable, meaning that setting something on it and not saving the result will result in discarding the modified session. Therefore, the “session” returned at the end of the exec is the original one.  
Cheers!

---

<div class="post-metadata">

**Author:** ![Julian1](https://avatars.discourse-cdn.com/v4/letter/j/258eb7/32.png) [@Julian1](https://community.gatling.io/u/Julian1)\
**Post date:** [August 5, 2015, 2:33am UTC](https://community.gatling.io/t/unable-to-increment-value-from-a-csv-file-looping/2434/3 "2015-08-05T02:33:38Z")

</div>

Hi Guillaume,

Thanks for your response!

> - A new element is extracted from a feeder only once per user, so it is normal that you get the same “userIdFeeder” for each step inside the repeat

I just tried that one out to know if that would help in incrementing the values from my feeder. But it doesn’t work as expected. All I know is that I must use session since email/username are varied. But I really am having trouble in incrementing the values from the feeder.  
What’s the best way to do it? Teach me, master. I’m desperate.

> - The session is immutable, meaning that setting something on it and not saving the result will result in discarding the modified session. Therefore, the “session” returned at the end of the exec is the original one

Will eliminating the last “session” do the trick?
