csvfilter
csvfilter copied to clipboard
fields don't work
$ csvfilter -f 1,2,3 file.csv
Expected: Output columns 1, 2, and 3 from file.csv for all rows
Actual: Only outputs columns 1, 2, and 3 from the first row.
It looks like the reason for this is:
fields = map(int, options.fields.split(',')) if options.fields else None
... which is being consumed after the first row:
output = [row[i] for i in self.fields if len(row) > i]
after which self.fields
becomes an empty array: []
A solution would be:
fields = list(map(int, options.fields.split(','))) if options.fields else None
This PR should resolve: https://github.com/codeinthehole/csvfilter/pull/12
Why hasnt this been merged in yet? The tool is broken.
In the meantime, if anyone is trying to get stuff done: pip install --upgrade git+https://github.com/lk-jeffpeck/csvfilter.git@ec433f14330fbbf5d41f56febfeedac22868a949
That will install Jeffs pull request on your machine and let you get on with your work.
Thanks Jeff btw
@silentwarrior @lk-jeffpeck Thanks for the fix and for the link to the fix.
+1 for me with @joaomcarlos fix it works perfectly
Thanks @lk-jeffpeck @joaomcarlos fix worked for me too 🙌
@codeinthehole Any chance it could be merged?