Hi,
I am trying to write the extracted data from session to csv file in gatling. I want to print something like below in tabular format
name age
hary 29
but it is printing as below everything in a single cell name age har29
I tried by using below code
val s1 = new File("./src/test/resources/data/Test.csv")
if(s1.exists()){
val writer = new PrintWriter(new FileOutputStream(new File("./src/test/resources/data/Test.csv"), true)) writer.write(session(“name”).as[String].trim)
writer.write(session(“age”).as[String].trim) writer.write("\n") writer.close()
}
else {
val writer = new PrintWriter(new FileOutputStream(new File("./src/test/resources/data/Test.csv"), true))
writer.print(“name”)
writer.println("\t age")
writer.write(session(“name”).as[String].trim +"\t"+session(“uploadTime”).as[String].trim) writer.write("\t"+session(“age”).as[String].trim) writer.write("\n") writer.close()
} session
Right now it is not printing the proper formatted data into csv instead it is writing everything to a single cell. Can someone please help me on how to print this in separate cells with headings name, age and data under these columns.
Thanks