Sha256: 118de40a5f3d82bc4be2cfdca3f1501992fb0c8b4528e5d4c3b223b4fb2ef786

Contents?: true

Size: 1.43 KB

Versions: 17

Compression:

Stored size: 1.43 KB

Contents

====== Option +col_sep+

Specifies the \String column separator to be used
for both parsing and generating.
The \String will be transcoded into the data's \Encoding before use.

Default value:
  CSV::DEFAULT_OPTIONS.fetch(:col_sep) # => "," (comma)

Using the default (comma):
  str = CSV.generate do |csv|
    csv << [:foo, 0]
    csv << [:bar, 1]
    csv << [:baz, 2]
  end
  str # => "foo,0\nbar,1\nbaz,2\n"
  ary = CSV.parse(str)
  ary # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]

Using +:+ (colon):
  col_sep = ':'
  str = CSV.generate(col_sep: col_sep) do |csv|
    csv << [:foo, 0]
    csv << [:bar, 1]
    csv << [:baz, 2]
  end
  str # => "foo:0\nbar:1\nbaz:2\n"
  ary = CSV.parse(str, col_sep: col_sep)
  ary # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]

Using +::+ (two colons):
  col_sep = '::'
  str = CSV.generate(col_sep: col_sep) do |csv|
    csv << [:foo, 0]
    csv << [:bar, 1]
    csv << [:baz, 2]
  end
  str # => "foo::0\nbar::1\nbaz::2\n"
  ary = CSV.parse(str, col_sep: col_sep)
  ary # => [["foo", "0"], ["bar", "1"], ["baz", "2"]]

Using <tt>''</tt> (empty string):
  col_sep = ''
  str = CSV.generate(col_sep: col_sep) do |csv|
    csv << [:foo, 0]
    csv << [:bar, 1]
    csv << [:baz, 2]
  end
  str # => "foo0\nbar1\nbaz2\n"

---

Raises an exception if parsing with the empty \String:
  col_sep = ''
  # Raises ArgumentError (:col_sep must be 1 or more characters: "")
  CSV.parse("foo0\nbar1\nbaz2\n", col_sep: col_sep)

Version data entries

17 entries across 17 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/common/col_sep.rdoc
fluent-plugin-openlineage-light-0.1.4 vendor/bundle/ruby/3.3.0/gems/csv-3.3.0/doc/csv/options/common/col_sep.rdoc
fluent-plugin-openlineage-light-0.1.3 vendor/bundle/ruby/3.3.0/gems/csv-3.3.0/doc/csv/options/common/col_sep.rdoc
fluent-plugin-openlineage-0.1.0 vendor/bundle/ruby/3.3.0/gems/csv-3.3.0/doc/csv/options/common/col_sep.rdoc
csv-3.3.0 doc/csv/options/common/col_sep.rdoc
csv-3.2.9 doc/csv/options/common/col_sep.rdoc
csv-3.2.8 doc/csv/options/common/col_sep.rdoc
csv-3.2.7 doc/csv/options/common/col_sep.rdoc
csv-3.2.6 doc/csv/options/common/col_sep.rdoc
csv-3.2.5 doc/csv/options/common/col_sep.rdoc
csv-3.2.4 doc/csv/options/common/col_sep.rdoc
csv-3.2.3 doc/csv/options/common/col_sep.rdoc
csv-3.2.2 doc/csv/options/common/col_sep.rdoc
csv-3.2.1 doc/csv/options/common/col_sep.rdoc
csv-3.2.0 doc/csv/options/common/col_sep.rdoc
csv-3.1.9 doc/csv/options/common/col_sep.rdoc
csv-3.1.8 doc/csv/options/common/col_sep.rdoc