csvkitHow to fetch unique values with csvkit?
csvkit is a suite of command-line tools for working with CSV, the most popular being csvcut and csvgrep.
csvcut can be used to fetch unique values from a CSV file. For example, to fetch the unique values from the "Name" column of a CSV file named "example.csv":
csvcut -c Name example.csv | sort | uniq
The output of this command will be a list of unique values from the "Name" column:
Alice
Bob
John
The command consists of three parts:
-
csvcut -c Name example.csv: This part of the command usescsvcutto select the "Name" column from the "example.csv" file. -
sort: This part of the command sorts the output of thecsvcutcommand. -
uniq: This part of the command filters out any duplicate values from the sorted output.
For more information about csvkit, see the csvkit documentation.
More of Csvkit
- How to split a csv file with csvkit?
- How to reorder columns with csvkit?
- How to use csvkit on Windows?
- How to remove duplicates with csvkit?
- How to rename a column with csvkit?
- How to install csvkit on a Mac?
- How to merge columns with csvkit?
- How to convert JSON to CSV using csvkit?
- How to extract a column from a CSV file using csvkit?
- How to change the encoding in csvkit?
See more codes...