Skip to content

Commit

Permalink
Merge 044c0d5 into 120d7c9
Browse files Browse the repository at this point in the history
  • Loading branch information
dannguyen committed Oct 29, 2020
2 parents 120d7c9 + 044c0d5 commit 0e0aaf2
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
2 changes: 1 addition & 1 deletion csvkit/utilities/csvstack.py
Expand Up @@ -73,7 +73,7 @@ def main(self):
else:
row = next(rows, [])

headers = make_default_headers(len(row))
headers = list(make_default_headers(len(row)))

if i == 0:
if has_groups:
Expand Down
57 changes: 56 additions & 1 deletion tests/test_utilities/test_csvstack.py
Expand Up @@ -53,9 +53,64 @@ def test_filenames_grouping(self):
['dummy2.csv', '1', '2', '3'],
])

def test_no_header_row(self):
class TestNoHeaderRow(TestCSVStack):

def test_no_header_row_basic(self):
self.assertRows(['--no-header-row', 'examples/no_header_row.csv', 'examples/no_header_row2.csv'], [
['a', 'b', 'c'],
['1', '2', '3'],
['4', '5', '6'],
])

def test_grouped_manual_and_named_column(self):
self.assertRows(
[
"--no-header-row",
"--groups",
"foo,bar",
"-n",
"hey",
"examples/dummy.csv",
"examples/dummy3.csv",
],
[
["hey", "a", "b", "c"],
["foo", "a", "b", "c"],
["foo", "1", "2", "3"],
["bar", "a", "b", "c"],
["bar", "1", "2", "3"],
["bar", "1", "4", "5"],
],
)

def test_grouped_filenames(self):
self.assertRows(
[
"-H",
"--filenames",
"examples/no_header_row.csv",
"examples/no_header_row2.csv",
],
[
["group", "a", "b", "c"],
["no_header_row.csv", "1", "2", "3"],
["no_header_row2.csv", "4", "5", "6"],
],
)

def test_grouped_filenames_and_named_column(self):
self.assertRows(
[
"-H",
"--filenames",
"-n",
"hello",
"examples/no_header_row.csv",
"examples/no_header_row2.csv",
],
[
["hello", "a", "b", "c"],
["no_header_row.csv", "1", "2", "3"],
["no_header_row2.csv", "4", "5", "6"],
],
)

0 comments on commit 0e0aaf2

Please sign in to comment.