Open tomhelmer opened 5 years ago
I have created a fork with a custom cast function like this :
if (csvOpts.cast) { csvOpts.cast = function(value, context) { if (isFinite(value) && !value.startsWith('0')) { return parseInt(value); } else if (_.toLower(value) === 'false') { return false; } else if (_.toLower(value) === 'true') { return true; } else { return value; } } }
This is matching my dataset, others might have floats, dates etc. It would be nice if the casting could be defined in the config file per field.
Hi
I have a CSV with booleans represented as the string true or false. I wan't these to be casted to booleans. The 'cast' option on payload defaults to true. The default cast function in csv-parse don't handle casting true|false to booleans. According to the documentation:
https://csv.js.org/parse/options/cast/
.. this can be the function handling the casting.
It would be nice if you injected a cast function handling true|false. It looks like you would have to copy the default casting functionality from csv-parse as well.. You can't stack your own parse on top of the default.
https://github.com/artilleryio/artillery/blob/aeec2d0ce3d2633a773590b7fa7a588970f622c2/lib/commands/run.js#L251