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

Adding a method to extract unique rows #352

Open
ianengelbrecht opened this issue Nov 6, 2024 · 1 comment
Open

Adding a method to extract unique rows #352

ianengelbrecht opened this issue Nov 6, 2024 · 1 comment

Comments

@ianengelbrecht
Copy link

Such a great tool, all it needs to make it perfect is a 'distinct' or 'unique' command to deduplicate a dataset...

@janxkoci
Copy link

janxkoci commented Dec 28, 2024

+1

In the meantime, you can try one of these:

# awk
xsv cat data.csv | awk '!a[$0]++' > uniq_data.csv
# miller
xsv cat data.csv | mlr -c uniq -a > uniq_data.csv

Awk should be available on most systems, while miller is easy to install, as it's a Go program with zero dependencies. Both are quite fast, but if speed is important, mawk can help a lot.

PS: contrary to the standard Unix command uniq the above tools don't require sorted input and will keep your data in the original order, just deduplicated 😉

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

2 participants