# Dynamic feeders - help!

**URL:** <https://community.gatling.io/t/dynamic-feeders-help/5938>\
**Category:** Gatling (Open-Source)\
**Created:** [December 16, 2020, 7:02pm UTC](https://community.gatling.io/t/dynamic-feeders-help/5938 "2020-12-16T19:02:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sharanya\_Krishnamoor](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@Sharanya\_Krishnamoor](https://community.gatling.io/u/Sharanya_Krishnamoor)\
**Post date:** [December 16, 2020, 7:02pm UTC](https://community.gatling.io/t/dynamic-feeders-help/5938/1 "2020-12-16T19:02:16Z")

</div>

I have a method that generates data and writes to a csv file in before method

val outputFile = new BufferedWriter(new FileWriter(“src/test/resources/primarycompany.csv”))

val csvWriter = new CSVWriter(outputFile, ‘\n’, CSVWriter.NO\_QUOTE\_CHARACTER)

before{  
createContact()  
}

def createContact(): Unit = {  
var noOfContacts: Int = 3  
listOfRecords += csvSchema  
for (i ← 0 until noOfContacts) {  
api.data = new JSONObject  
api.setContacts()  
response = api.createContact(path, 201)  
ContactID = response.path(ContactsEnum.mcr\_contact\_id.keys)  
primaryContactIDList.add(ContactID.toString)  
}  
try{  
listOfRecords += GetStringArray(primaryContactIDList)  
csvWriter.writeAll(listOfRecords.toList)  
}  
finally{  
csvWriter.close()  
}  
}

As seen above am writing the values to primarycompany.csv

I wanted to use this file as feeder but " **Feeder source is empty"** though it has values in it.

Help pls!

**_The content of this e-mail is confidential and is intended solely for the use of the individual or entity to whom it is addressed. If you have received this e-mail by mistake, please reply to this e-mail and follow with its deletion. If you are not the intended recipient, please note that it shall be considered unlawful to copy, forward or in any manner reveal the contents of this e-mail or any part thereof to anyone. Although Freshworks has taken reasonable precautions to ensure no malware is present in this e-mail, Freshworks cannot accept responsibility for any loss or damage arising from the use of this e-mail or attachments._**

---

<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:** [December 17, 2020, 4:51pm UTC](https://community.gatling.io/t/dynamic-feeders-help/5938/2 "2020-12-17T16:51:34Z")

</div>

Hello,

First, `before` hook is run after the initialization and “before” the actual simulation (see [the lifecycle](https://gatling.io/docs/current/general/simulation_structure/#hooks)).

The feeder is initialized before the `before` hook and then has already check that the source is empty or not.

Solution: you should use the `batch` [loading mode](https://gatling.io/docs/current/session/feeder/#loading-mode)

But, sadly, we had an issue with this loading mode, and we fix in the next release.  
You’ll find the fix in Gatling 3.5.0 (release in progress)

Sébastien,

---

<div class="post-metadata">

**Author:** ![Sharanya\_Krishnamoor](https://avatars.discourse-cdn.com/v4/letter/s/3ec8ea/32.png) [@Sharanya\_Krishnamoor](https://community.gatling.io/u/Sharanya_Krishnamoor)\
**Post date:** [December 17, 2020, 8:47pm UTC](https://community.gatling.io/t/dynamic-feeders-help/5938/3 "2020-12-17T20:47:31Z")

</div>

Great! Thank you.
