Permalink
Browse files

csvlook respects --no-header-row

  • Loading branch information...
jpmckinney committed Sep 5, 2012
1 parent 9cbcd32 commit 0805968e18453161672b985483f165ce910781a1
Showing with 17 additions and 1 deletion.
  1. +1 −1 csvkit/utilities/csvlook.py
  2. +2 −0 examples/no_header_row3.csv
  3. +14 −0 tests/test_utilities/test_csvlook.py
@@ -40,7 +40,7 @@ def main(self):
self.output_file.write(('| %s |\n' % ('|'.join(output))).encode('utf-8'))
if i == 0 or i == len(rows) - 1:
if (i == 0 and not self.args.no_header_row) or i == len(rows) - 1:
self.output_file.write('%s\n' % divider)
def launch_new_instance():
@@ -0,0 +1,2 @@
1,2,3
4,5,6
@@ -22,3 +22,17 @@ def test_simple(self):
self.assertEqual(input_file.next(), '| 1 | 4 | 5 |\n')
self.assertEqual(input_file.next(), '|----+---+----|\n')
def test_no_header(self):
args = ['--no-header-row', 'examples/no_header_row3.csv']
output_file = StringIO.StringIO()
utility = CSVLook(args, output_file)
utility.main()
input_file = StringIO.StringIO(output_file.getvalue())
self.assertEqual(input_file.next(), '|----+---+----|\n')
self.assertEqual(input_file.next(), '| 1 | 2 | 3 |\n')
self.assertEqual(input_file.next(), '| 4 | 5 | 6 |\n')
self.assertEqual(input_file.next(), '|----+---+----|\n')

0 comments on commit 0805968

Please sign in to comment.