read csv files from jar file

470 views
Skip to first unread message

Yuri K

unread,
Apr 4, 2013, 12:16:54 PM4/4/13
to gat...@googlegroups.com
Hi all,

here is the code snippet 

csv("/data/user_information.csv")

/data/user_information.csv is  packed inside of jar file which is in classpath. Everything is built with sbt. Is there a way to read   user_information.csv with csv function from jar file which is in classpath.

  val path = getClass.getResource("/data/user_information.csv").getFile
  val  file:File  = new File(new java.io.File(path))
  csv(file)

that snippet does not work

Regards,
Yuri


Stéphane Landelle

unread,
Apr 5, 2013, 1:27:25 AM4/5/13
to gat...@googlegroups.com
The csv built-in currently locates the file on the file system, not in the classpath (but that's an interesting use case, we might consider implementing it), so basically, the answer is: currently no.

Anyway, csv(file) only produces a Array[Map[String, String]] that's implicitly converted into a feeder, so you can just copy SeparatedValuesParser logic in your snippet:

Just use Source.fromInputStream instead of fromFile.

Cheers,

Stéphane



2013/4/4 Yuri K <yko...@gmail.com>


--
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/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages