Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fields don't work #13

Open
lk-jeffpeck opened this issue Mar 7, 2018 · 4 comments
Open

fields don't work #13

lk-jeffpeck opened this issue Mar 7, 2018 · 4 comments

Comments

@lk-jeffpeck
Copy link

lk-jeffpeck commented Mar 7, 2018

$ 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:
#12

@joaomcarlos
Copy link

joaomcarlos commented Mar 19, 2019

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

@keenhl
Copy link

keenhl commented Jul 9, 2019

@silentwarrior @lk-jeffpeck Thanks for the fix and for the link to the fix.

@pinturic
Copy link

+1 for me with @joaomcarlos fix it works perfectly

@Eddie901
Copy link

Eddie901 commented Jun 7, 2023

Thanks @lk-jeffpeck @joaomcarlos fix worked for me too 🙌

@codeinthehole Any chance it could be merged?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants