# Feeding csv file with dynamic file name

**URL:** https://community.gatling.io/t/feeding-csv-file-with-dynamic-file-name/8370
**Category:** General discussions
**Created:** [October 16, 2023, 9:52am UTC](https://community.gatling.io/t/feeding-csv-file-with-dynamic-file-name/8370 "2023-10-16T09:52:54Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![subhah](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@subhah](https://community.gatling.io/u/subhah)
#### Post date: [October 16, 2023, 9:52am UTC](https://community.gatling.io/t/feeding-csv-file-with-dynamic-file-name/8370/1 "2023-10-16T09:52:54Z")

</div>

Hi all, need a help on how to feed a csv with dynamic file name. In the below scenario, I am getting compiler error at Line 6 “No candidates found for method call session.getString(“filename”)”  
Requirement: From the first csv, i get organization name and the new csv file name is “{orgname}.csv” which i want to feed again

```java
   ScenarioBuilder scn = scenario("foo")
             .feed(csv("TestData/OrgwiseStores.csv"))
                   .exec(
                                 session->session.set("org", session.getString("Org"))
                                         .set("filename", "Testdata/" + session.getString("Org") + ".csv"))
                  .feed(csv(session->session.getString("filename")).queue())
                  .exec(session->{
                                 String item = session.getString("I_Item");
                                 System.out.print("Org-->" + "item -->" + item);
                                 return session;
                             }
                          );

```

---

<div class="post-metadata">

### Author: ![sbrevet](https://dub1.discourse-cdn.com/flex013/user_avatar/community.gatling.io/sbrevet/32/830_2.png) [@sbrevet](https://community.gatling.io/u/sbrevet)
#### Post date: [October 16, 2023, 10:16am UTC](https://community.gatling.io/t/feeding-csv-file-with-dynamic-file-name/8370/2 "2023-10-16T10:16:34Z")

</div>

Hi @subhah,

Our feeder constructors (`csv`) don’t take session API as argument, they should be instantiated BEFORE the start of the simulation.

Feeders are meant to be shared between virtual users and it’s not possible if each user create its own feeder.

Your use case may be interesting, but you will have to manage your own way to manipulate session attributes based on previous values.

Feel free to share your solution with our community!

Good luck!  
Cheers!

---

<div class="post-metadata">

### Author: ![subhah](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@subhah](https://community.gatling.io/u/subhah)
#### Post date: [October 16, 2023, 11:06am UTC](https://community.gatling.io/t/feeding-csv-file-with-dynamic-file-name/8370/3 "2023-10-16T11:06:36Z")

</div>

Hi @sbrevet ,

Thanks for your response ! I tried different alternatives and in below code there were no compiler errors. However, line 8 prints correct value, line 11 printed “null”. “I\_Item” is from second csv file. Seems the second csv is not getting into memory ?

1 public static String fname=“TestData/OrgwiseStores.csv”;  
2 public static String fname1;  
3 ScenarioBuilder scn = scenario(“foo”)  
4 .feed(csv(fname).queue())  
5 .exec(  
6 session-\> {  
7 fname1 = “Testdata/” + session.getString(“Org”) + “.csv”;  
8 System.out.println("org " + fname1);  
9 feed(csv(fname1));  
10 String item = session.getString(“I\_Item”);  
11 System.out.print(“Org–\>” + “item --\>” + item);  
12 return session;  
13 }  
14 );

---

<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: [October 16, 2023, 11:22am UTC](https://community.gatling.io/t/feeding-csv-file-with-dynamic-file-name/8370/4 "2023-10-16T11:22:09Z")

</div>

Really, you can not use Gatling feeders this way. This is something you have to implement yourself, possibly with the same CSV parser than us: [https://simpleflatmapper.org/](https://simpleflatmapper.org/), but not with our built-ins.

---

<div class="post-metadata">

### Author: ![subhah](https://avatars.discourse-cdn.com/v4/letter/s/e95f7d/32.png) [@subhah](https://community.gatling.io/u/subhah)
#### Post date: [October 16, 2023, 11:30am UTC](https://community.gatling.io/t/feeding-csv-file-with-dynamic-file-name/8370/5 "2023-10-16T11:30:40Z")

</div>

Thanks @slandelle . Will check
