Repository: wireservice/csvkit

Issue:
csvstack to support --skip-lines
First , great library.

It was very handy in searching big csv files , i just needed to search a complete folder full of csv that each file has a header that should be ignored by using latest version 1.0.2 --skip-lines it was possible but file by file . i tried using csvstack but it did not recognise the parameter --skip-lines 

```
Alis-Mac-mini:sonus shahbour$ csvgrep --skip-lines 1 -c 20 -r "^449" -H  20170219013000.1014D6F.ACT.gz | csvgrep -c 21 -r "^639"  | csvcut  -c 20,21    
t,u
44971506961058,639398219637
44971504921587,639106889971
44971569097874,639291643991
44971568622691,639101981790
44971543461612,639495761895
44971502473650,639287415793
44971543544583,639183191196
44971569097874,639291643991
44971566267135,639293255451
44971507677524,639108700472
```

```
Alis-Mac-mini:sonus shahbour$ csvstack -H --skip-lines 1 * | csvgrep -c 20 -r "^449" | csvgrep -c 21 -r "^639"  | csvcut  -c 20,21                 
usage: csvstack [-h] [-d DELIMITER] [-t] [-q QUOTECHAR] [-u {0,1,2,3}] [-b]
                [-p ESCAPECHAR] [-z FIELD_SIZE_LIMIT] [-e ENCODING] [-S] [-H]
                [-v] [-l] [--zero] [-V] [-g GROUPS] [-n GROUP_NAME]
                [--filenames]
                FILE [FILE ...]
csvstack: error: unrecognized arguments: --skip-lines
```


Discussion:

Patch:
diff --git a/csvkit/utilities/csvstack.py b/csvkit/utilities/csvstack.py
index bf1c00b..39d544d 100644
--- a/csvkit/utilities/csvstack.py
+++ b/csvkit/utilities/csvstack.py
@@ -9,7 +9,7 @@ from csvkit.cli import CSVKitUtility, make_default_headers
 
 class CSVStack(CSVKitUtility):
     description = 'Stack up the rows from multiple CSV files, optionally adding a grouping value.'
-    override_flags = ['f', 'K', 'L', 'date-format', 'datetime-format']
+    override_flags = ['f', 'L', 'date-format', 'datetime-format']
 
     def add_arguments(self):
         self.argparser.add_argument(metavar="FILE", nargs='+', dest='input_paths', default=['-'],
@@ -45,6 +45,14 @@ class CSVStack(CSVKitUtility):
         output = agate.csv.writer(self.output_file, **self.writer_kwargs)
 
         for i, f in enumerate(self.input_files):
+            if isinstance(self.args.skip_lines, int):
+                skip_lines = self.args.skip_lines
+                while skip_lines > 0:
+                    f.readline()
+                    skip_lines -= 1
+            else:
+                raise ValueError('skip_lines argument must be an int')
+
             rows = agate.csv.reader(f, **self.reader_kwargs)
 
             # If we have header rows, use them


Test patch:
diff --git a/tests/test_utilities/test_csvstack.py b/tests/test_utilities/test_csvstack.py
index abae02d..2921f2f 100644
--- a/tests/test_utilities/test_csvstack.py
+++ b/tests/test_utilities/test_csvstack.py
@@ -19,6 +19,13 @@ class TestCSVStack(CSVKitTestCase, EmptyFileTests):
         with patch.object(sys, 'argv', [self.Utility.__name__.lower(), 'examples/dummy.csv']):
             launch_new_instance()
 
+    def test_skip_lines(self):
+        self.assertRows(['--skip-lines', '3', 'examples/test_skip_lines.csv', 'examples/test_skip_lines.csv'], [
+            ['a', 'b', 'c'],
+            ['1', '2', '3'],
+            ['1', '2', '3'],
+        ])
+
     def test_single_file_stack(self):
         self.assertRows(['examples/dummy.csv'], [
             ['a', 'b', 'c'],