Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion lib/csv.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2033,6 +2033,7 @@ def create_stringio(str, mode, opts)
#
def initialize(data,
col_sep: ",",
sep: nil,
row_sep: :auto,
quote_char: '"',
field_size_limit: nil,
Expand All @@ -2059,6 +2060,11 @@ def initialize(data,
write_empty_value: "")
raise ArgumentError.new("Cannot parse nil as CSV") if data.nil?

if sep && col_sep != ","
raise ArgumentError, "Cannot specify both :sep and :col_sep"
end
actual_sep = sep || col_sep

if data.is_a?(String)
if encoding
if encoding.is_a?(String)
Expand Down Expand Up @@ -2094,7 +2100,7 @@ def initialize(data,
max_field_size = field_size_limit - 1
end
@parser_options = {
column_separator: col_sep,
column_separator: actual_sep,
row_separator: row_sep,
quote_character: quote_char,
max_field_size: max_field_size,
Expand Down