Sha256: df984203f9fa3f4c27869c8ca1d26c737d431d95f5bf57ddd0472796b5087e41

Contents?: true

Size: 1.46 KB

Versions: 19

Compression:

Stored size: 1.46 KB

Contents

====== Option +converters+

Specifies converters to be used in parsing fields.
See {Field Converters}[#class-CSV-label-Field+Converters]

Default value:
  CSV::DEFAULT_OPTIONS.fetch(:converters) # => nil

The value may be a field converter name
(see {Stored Converters}[#class-CSV-label-Stored+Converters]):
  str = '1,2,3'
  # Without a converter
  array = CSV.parse_line(str)
  array # => ["1", "2", "3"]
  # With built-in converter :integer
  array = CSV.parse_line(str, converters: :integer)
  array # => [1, 2, 3]

The value may be a converter list
(see {Converter Lists}[#class-CSV-label-Converter+Lists]):
  str = '1,3.14159'
  # Without converters
  array = CSV.parse_line(str)
  array # => ["1", "3.14159"]
  # With built-in converters
  array = CSV.parse_line(str, converters: [:integer, :float])
  array # => [1, 3.14159]

The value may be a \Proc custom converter:
(see {Custom Field Converters}[#class-CSV-label-Custom+Field+Converters]):
  str = ' foo  ,  bar  ,  baz  '
  # Without a converter
  array = CSV.parse_line(str)
  array # => [" foo  ", "  bar  ", "  baz  "]
  # With a custom converter
  array = CSV.parse_line(str, converters: proc {|field| field.strip })
  array # => ["foo", "bar", "baz"]

See also {Custom Field Converters}[#class-CSV-label-Custom+Field+Converters]

---

Raises an exception if the converter is not a converter name or a \Proc:
  str = 'foo,0'
  # Raises NoMethodError (undefined method `arity' for nil:NilClass)
  CSV.parse(str, converters: :foo)

Version data entries

19 entries across 19 versions & 4 rubygems

Version Path
fluent-plugin-nuopenlineage-light-0.1.0 vendor/bundle/ruby/3.3.0/gems/csv-3.3.0/doc/csv/options/parsing/converters.rdoc
fluent-plugin-openlineage-light-0.1.4 vendor/bundle/ruby/3.3.0/gems/csv-3.3.0/doc/csv/options/parsing/converters.rdoc
fluent-plugin-openlineage-light-0.1.3 vendor/bundle/ruby/3.3.0/gems/csv-3.3.0/doc/csv/options/parsing/converters.rdoc
fluent-plugin-openlineage-0.1.0 vendor/bundle/ruby/3.3.0/gems/csv-3.3.0/doc/csv/options/parsing/converters.rdoc
csv-3.3.0 doc/csv/options/parsing/converters.rdoc
csv-3.2.9 doc/csv/options/parsing/converters.rdoc
csv-3.2.8 doc/csv/options/parsing/converters.rdoc
csv-3.2.7 doc/csv/options/parsing/converters.rdoc
csv-3.2.6 doc/csv/options/parsing/converters.rdoc
csv-3.2.5 doc/csv/options/parsing/converters.rdoc
csv-3.2.4 doc/csv/options/parsing/converters.rdoc
csv-3.2.3 doc/csv/options/parsing/converters.rdoc
csv-3.2.2 doc/csv/options/parsing/converters.rdoc
csv-3.2.1 doc/csv/options/parsing/converters.rdoc
csv-3.2.0 doc/csv/options/parsing/converters.rdoc
csv-3.1.9 doc/csv/options/parsing/converters.rdoc
csv-3.1.8 doc/csv/options/parsing/converters.rdoc
csv-3.1.7 doc/csv/options/parsing/converters.rdoc
csv-3.1.6 doc/options/parsing/converters.rdoc