har123
har123

Reputation: 59

Write Extracted values to csv or text Gatling

I am trying to write extracted values from session to the csv file in a scala gatling script , I am extracting multiple fields and need to write data to multiple columns in csv . Can someone please suggest how to implement this.

Upvotes: 0

Views: 1365

Answers (1)

dmle
dmle

Reputation: 3658

You can use session to first save all the required values and later save it to the file via exec call:

exec(
...
.check(regex("data(.*?)\"").findAll.saveAs("userIds")))
)
.exec( session => {        
   scala.reflect.io.File("data.csv").appendAll(session("userIds").as[Seq[String]].mkString(",")+"\n")
   session
})

in example above I assume you get a list of userId and you write it in a single line. You can check more advanced example for writing headers & rows here

Upvotes: 0

Related Questions