gatling/Scala: Write custom feeder (read csv from url) - random iterator?
<p>I am new to scala  and I am trying to write a custom feeder for gatling that reads a csv file from a url (similar jsonUrl-Feeder).</p>

<p>I am unsure about how to do this. I tried the following, but now I need to implement additional methods:</p>

<pre><code>package common

import scala.io.Source
import scala.collection.mutable.ListBuffer

class CsvURLFeeder(url: String) extends Map[String, String] {

 val source = Source.fromURL(url)
 val reader = source.bufferedReader()

 val attributeName = reader.readLine()

 var list : ListBuffer[Map[String, String]] = new ListBuffer[Map[String, String]]() 

 val input = Stream.continually(reader readLine)


 for( line &lt;- input){
   list += Map(attributeName-&gt; line) 
 }

 def getFeeder() : Iterator[Map[String, String]]  = {
   return list.iterator
 }

}
</code></pre>

<p>missing methods:</p>

<pre><code>// Members declared in scala.collection.immutable.Map
def +[B1 &gt;: String](kv: (String, B1)): scala.collection.immutable.Map[String,B1] = ???

// Members declared in scala.collection.MapLike
def -(key: String): scala.collection.immutable.Map[String,String] = ???
def get(key: String): Option[String] = ???
1def iterator: Iterator[(String, String)] = ???
</code></pre>

<p>Also, I have no idea how to make the iterator random. I don't want to go through the list one by one.</p>

<p>Isn't there a similar feeder who does the same stuff for me?
Or what would be the best way to implement such a feeder?</p>

<p>Thanks in advance.</p>

<p><strong>UPDATE</strong></p>

<p>Took away the part "extends Map[String, String]" because it is obviously not doing anything. Now - of course - I don't need to implement those methods any more.</p>

<p>Now I can see that something is wrong with the for-loop... it never stops printing "null". Also, the first line is wrong. It is "Stream("actual first line",?)".</p>

<p><strong>UPDATE 2</strong>
I changed the reading part to </p>

<pre><code>var list : ListBuffer[Map[String, String]] = new ListBuffer[Map[String, String]]() 

var line = "";
while ( {line = reader.readLine ; line != null} ){
  list += Map(attributeName-&gt; line) 
}
</code></pre>

<p>... and this works now!! Cool.</p>

<p>But it looks pretty ugly. Is there a more elegant way to do that?</p>