Skip to content

Commit 34e21fa

Browse files
BurdetteLamarkou
andauthored
csv-filter: add --row-sep (#335)
Co-authored-by: Sutou Kouhei <kou@cozmixng.org>
1 parent 29723a0 commit 34e21fa

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

bin/csv-filter

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ parser.on('--output-row-sep=SEPARATOR',
4242
options[:output_row_sep] = value
4343
end
4444

45+
parser.on('-r', '--row-sep=SEPARATOR',
46+
'Row separator string.') do |value|
47+
options[:row_sep] = value
48+
end
49+
4550
begin
4651
parser.parse!
4752
rescue OptionParser::InvalidOption

test/csv/test_csv_filter.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,14 @@ def test_option_output_row_sep
110110
assert_equal(["aaa,bbb,ccc:ddd,eee,fff:", ""],
111111
run_csv_filter(csv, "--output-row-sep=:"))
112112
end
113+
114+
def test_option_row_sep
115+
csv = "aaa,bbb,ccc:ddd,eee,fff:"
116+
assert_equal(["aaa,bbb,ccc:ddd,eee,fff:", ""],
117+
run_csv_filter(csv, "--row-sep=:"))
118+
assert_equal(["aaa,bbb,ccc.ddd,eee,fff.", ""],
119+
run_csv_filter(csv, "--row-sep=.", "--input-row-sep=:"))
120+
assert_equal(["aaa,bbb,ccc.ddd,eee,fff.", ""],
121+
run_csv_filter(csv, "--row-sep=:", "--output-row-sep=."))
122+
end
113123
end

0 commit comments

Comments
 (0)