Change -l to use "original" line numbers for csvgrep ? #155

JoeGermuska opened this Issue Mar 5, 2012 · 3 comments

4 participants


I was surprised by the behavior of csvgrep -l -- the lines are numbered from 1 to N consecutively based on the post-grep output. I was kind of expecting to see the original line numbers.

This would be a backwards-incompatible change, in a sense, so not sure how you want to handle it.


Yeah, I'd probably call this a bug, though it may be non-trivial to fix as I believe the line-numbering is baked into the writer, not the logic of the of the tool. Also, various other tools inherent this parameter as well, so there may be a network of consequences to changing it. It should probably a 0.5 change (not 0.4.5) if we're going to do it.


I encounter the same problem but the way to make it happens can be to pipe

csvcut -e 'latin-1' -d ';' -l myfile.csv| csvgrep -c 2 -i -r "[0-9]{7}[a-zA-Z]"

First part says take the file myfile.csv and add a line number for each line, using encoding latin-1 and semi-colon delimiter. Pipe the result in csvgrep where column 2 (before 1 without numbering) do not match the regex (-i option like inverse)
If this solution is worth, add it into some FAQ and close the ticket ;)

@onyxfish onyxfish added this to the 1.0 milestone Sep 20, 2014
wireservice member

I think we can add the line numbers with the reader, and adjust the column_ids appropriately.

@jpmckinney jpmckinney modified the milestone: 1.0, Quick Feb 5, 2016
@jpmckinney jpmckinney closed this in daf3335 Feb 9, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment