Questions for CSV Users

Burdette Lamar - Nov 6 '21 - - Dev Community

A while back I learned from the good folks over at ruby/csv that for performance reasons, CSV methods do not type-check their arguments. Therefore an invalid argument will eventually cause an error somewhere downstream. The original cause of the error may or may not be obvious.


[Added, for clarity.]

For example, in the method call CSV.new(s), s must be String-convertible or an IO stream open for reading, but this is not checked when the call is executed. An invalid s is discovered only later, when there's an attempt to read from it.


I'm considering creating a gem (possibly called csv_debug) such that:

  • require 'csv_debug' would transparently perform type checking, raising an exception on violation.
  • Changing to require 'csv' would return things to normal.

For example, CSV.new(data, **options) takes 24 options, most of which are not used immediately. The gem would type-check each option (as well as data) as soon as the method is called.

Using the gem would allow an application that uses CSV to have type checking in development, but no type checking in production.

Questions:

  • Would this gem be useful?
  • Is there a better name for the gem? (There's already a gem called csv_safe that guards against dangerous CSV data.)
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .