Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

csvlook respects --no-header-row

  • Loading branch information...
commit 0805968e18453161672b985483f165ce910781a1 1 parent 9cbcd32
@jpmckinney jpmckinney authored
View
2  csvkit/utilities/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():
View
2  examples/no_header_row3.csv
@@ -0,0 +1,2 @@
+1,2,3
+4,5,6
View
14 tests/test_utilities/test_csvlook.py
@@ -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')
+
Please sign in to comment.
Something went wrong with that request. Please try again.