Write data into csv file

1,400 views
Skip to first unread message

gatling_user

unread,
Aug 26, 2014, 10:40:18 AM8/26/14
to gat...@googlegroups.com
Hi,

I want to write some session details of the running simulation into csv file so that i use the data from csv file for running another script. Is there anyway in gatling to achieve this?

Stéphane Landelle

unread,
Aug 26, 2014, 12:15:20 PM8/26/14
to gat...@googlegroups.com


2014-08-26 16:40 GMT+02:00 gatling_user <nacc...@gmail.com>:
Hi,

I want to write some session details of the running simulation into csv file so that i use the data from csv file for running another script. Is there anyway in gatling to achieve this?

--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

iMuVoDelPasso

unread,
Nov 30, 2017, 9:24:55 AM11/30/17
to Gatling User Group
Hello Stephane ,

I need to realize the same but i did not understand in which way the link you sended was an answer .

Could you help ?

Regards

Adam Artajew

unread,
Dec 1, 2017, 3:42:47 AM12/1/17
to Gatling User Group
Try this:

package loadtest

import com.github.tototoshi.csv._
import io.gatling.core.Predef._

object SaveDataToFile {

  createEmptyCSVFile()

  implicit object CSVFormat extends DefaultCSVFormat {
    override val delimiter = ';'
    override val lineTerminator = "\n"
  }

  def createEmptyCSVFile(): Unit = {
    val csv = CSVWriter.open(file = "data.csv", append = false)
    csv.writeRow(List(
      "timestamp",
      "session_user_id"
    ))
    csv.close()
  }

  def saveDataToFile() = exec(session => {
    val csv = CSVWriter.open(file = "data.csv", append = true)
    csv.writeRow(List(
      System.currentTimeMillis / 1000,
      session.userId
    ))
    csv.close()

    session
  })
}

// usage in scenario:
exec(SaveDataToFile())


Have fun!

nickshi...@gmail.com

unread,
Jun 1, 2018, 10:08:24 AM6/1/18
to Gatling User Group
Will it be performance efficient?
For example: 
I need to analyze the performance of an API which creates user and once the job is completed, it should clean up all those created users.
So I can use exec (exec(PostAPIForUser)) to call api which will create user and user your way to dump all responses in csv file so that i can use them in after method to read them and delete those created users.

But my query is will exec(SaveDataToFile()) will not affect performance analysis of exec(PostAPIForUser) as it will work in chaining or its impact will be negligible?

Thanks
Reply all
Reply to author
Forward
0 new messages