CSV parsing

I am trying to parse a CSV, but am running into problems between the DSL and Scala

package scraper

import au.com.bytecode.opencsv.CSVWriter
import java.io.BufferedWriter
import java.io.FileWriter
import java.io.StringWriter
import io.gatling.core.session.Session

import scala.collection.JavaConversions._

object writeSwaggerValues extends App {

  def createCSV () : Unit = {
    val out = new BufferedWriter(new FileWriter("/home/aram/session.csv"))
    val writer = new CSVWriter(out)
    val swaggerSchema = Array("nickname", "path", "method")

    val twitter = Array("${lastTweetsName}", "${lastTweetsPath}", "${lastTweetsMethod}")
    val forecast = Array("${forecastName}", "${forecastPath}", "${forecastMethod}")
    val listOfRecords = List(swaggerSchema, twitter, forecast)



error: overloaded method value exec with alternatives:
[ERROR] (scenario: io.gatling.core.structure.ScenarioBuilder)io.gatling.core.structure.ScenarioBuilder
[ERROR] (chains: Iterable[io.gatling.core.structure.ChainBuilder])io.gatling.core.structure.ScenarioBuilder
[ERROR] (chains: Iterator[io.gatling.core.structure.ChainBuilder])io.gatling.core.structure.ScenarioBuilder
[ERROR] (chains: io.gatling.core.structure.ChainBuilder*)io.gatling.core.structure.ScenarioBuilder
[ERROR] (actionBuilder: io.gatling.core.action.builder.ActionBuilder)io.gatling.core.structure.ScenarioBuilder
[ERROR] (sessionFunction: io.gatling.core.session.Expression[io.gatling.core.session.Session])io.gatling.core.structure.ScenarioBuilder
[ERROR] cannot be applied to (AnyVal)
[ERROR] .exec(writeSwaggerValues.createCSV)

The problem is inthe return type if I am correct. I think the DSL chainbuilder want me to return Session (that is the reason for the import), but they I get:

error: type mismatch;
[ERROR] found : Unit
[ERROR] required: io.gatling.core.session.Session
[ERROR] out.close()

Does anyone have a idea to solve this?

Thank you

You are returning the wrong type and I think the file I/O would be blocking.

Is this a pre-test to extract data needed for the load test proper?

Exactly. Basically I have a scraper in gatling that does one round. Then stores all the values in the session.

But I want to make a back up of my session values. I want to do this by writing to a Csv file. Then load the csv values to the real performance test.
But I cannot chain this simple csv witer in the .exec chain build because of the return value conflict.
Any idea’s?

I’d probably use a logger and Unix tools to parse it.

val logger = org.slf4j.LoggerFactory.getLogger(this.getClass)

.exec { session => logger.warn(session(“addComputer”).as[String]); session } // used warn to lessen the noise

You’ll need a logback.xml:

Or alternatively, post a gist of your logging code and simulation and I will try to get it to work.