Is there a way not to escape with \ in a csv feeder?

519 views
Skip to first unread message

Henri Tremblay

unread,
Oct 14, 2015, 3:36:10 PM10/14/15
to gat...@googlegroups.com
Hi,

My csv contains a json and is strictly compliant with the RFC. So the json is escaping with a backslash my double-quotes.

CSV should escape double-quotes by doubling them.

But since the backslash is seen as an escape character, it's getting removed and I don't want that.

Exemple of a csv line:

1,"{""value"":""\""this\""}"

and what I would expect to receive for the second field:

{"value":"\"this\"}

but I get:

{"value"":"""this"""}

I can I solve that?

Thanks
Henri

Stéphane LANDELLE

unread,
Oct 14, 2015, 3:46:21 PM10/14/15
to gat...@googlegroups.com
Sad thing.
I missed that the backslash escaping wasn't part of RFC4180, so I hardcoded it when I switched from opencsv to Jackson: https://github.com/gatling/gatling/blob/v2.2.0-M3/gatling-core/src/main/scala/io/gatling/core/feeder/SeparatedValuesParser.scala#L44

Currently, you'd either have to fork the feeder, or use rawSplit, and then convert the column to remove the outer double quotes. See Feeder doc: http://gatling.io/docs/2.1.7/session/feeder.html

Stéphane Landelle
Lead developer


--
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.

Henri Tremblay

unread,
Oct 14, 2015, 3:56:05 PM10/14/15
to Gatling User Group
Yes. I was getting there when reading the code.

But rawSplit will then separate the commas in my json if I'm not mistaken. So I will need to stitch my field back to sanity.

Right now, I'm looking for implementing my own stream function as in SeparatedValuesParser. But I first need to find out a working CSVParser configuration.

Henri Tremblay

unread,
Oct 14, 2015, 4:08:18 PM10/14/15
to Gatling User Group
Ok, using this does work:

CSVParser parser = new CSVParser(',', '"', '\0');

I can provide a patch when I have 2 minutes but how would you solve it? Set this by default to respect the RFC? Add a new method in FeederSupport that takes an escapeChar? Both?

Thanks
Henri

Stéphane LANDELLE

unread,
Oct 14, 2015, 4:20:16 PM10/14/15
to gat...@googlegroups.com
CSVParser is from opencsv and is getting out.
Please target master, ie 2.2.

  • Add a new Option[Char] parameter to SeparatedValuesParser methods.
  • Add new parameters to FeederSupport.separatedValues
  • Update Feeder doc
Thanks :)


Stéphane Landelle
Lead developer


Reply all
Reply to author
Forward
0 new messages