Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding unique Values from a file

Tags:

csv

I have a 6 mb sized csv file. I want to filter the data by column A & Column C so that I need to remove any duplicates. What is the easiest way to do it and how to do it. Any help is very much appreciated.

like image 478
mousey Avatar asked Apr 17 '26 21:04

mousey


1 Answers

cat foo.csv | cut -f2 -d , | sort | uniq

It will give you unique ids from 2nd column

cat foo.csv | cut -f1 -d , | sort | uniq

It will give you unique ids from 1st column

-f < number > : column number

-d  < space >< delimiter > : file delimiter 
like image 116
shweta Avatar answered Apr 20 '26 16:04

shweta