Need to remove some value in CSV file

Hi All

A .csv file containing multiple value on it. i need to remove some value from it. Please advise how can i find multiple value from that and remove itself. Please provide solution for this.

Thanks in advance.

Posting few lines of your csv file and the desired output format would help us to help you..

Hi

Below are the example value of .csv file.

"10002","UNIV OF WESTERN ONTARIO (OCUL) (#10002)","CON","I","A","","CANADA","Namer W","",""
"10003","NATIONAL CENTRAL UNIV un/pw (#10003)","CON","I","A","","TAIWAN","APAC1","",""
"10005","UNIV OF WINDSOR (OCUL) (#10005)","CON","I,K","A","","CANADA","Namer W","",""
"10006","CARLETON UNIV (OCUL) (#10006)","CON","I,SN.Q","A","","CANADA","Namer W","",""
"10009","NATIONAL TAIPEI UNIV OF TECH (#10009)","CON","I","A","","TAIWAN","APAC1","",""
"10017","YEUNGNAM UNIV (#10017)","CON","I","A","","KOREA","Lamer","",""
"10024","TIANJIN UNIV (#10024)","CON","I","A","","CHINA","APAC1","",""
"10036","UNIV OF MANITOBA (#10036)","CON","I","A","","CANADA","Namer W","",""
"10050","UNIV HEIDELBERG (#10050)","CON","A","A","","GERMANY","EUROPE PLUS","",""
"10055","DONG-EUI UNIV (#10055)","CON","I","A","","KOREA","Lamer","",""
"10056","KYUNGNAM UNIVERSITY (#10056)","CON","I","A","","KOREA","Lamer","",""
"10058","DUKE UNIV (#10058)","","I","A","NC","UNITED STATES","Namer E","",""
"10067","BEIJING JIAOTONG UNIV (NORTHERN JIAOTONG UNIV) (#10067)","CON","I, R","A","","CHINA","APAC1","",""
"10069","UNIV OF ELECTRONIC SCIENCE & TECH (#10069)","CON","I,R,K","A","","CHINA","APAC1","",""
"10074","UNIV OF BRISTOL (#10074)","CON","I","A","","UNITED KINGDOM","EUROPE PLUS","",""
"10076","SUN YAT-SEN UNIV (#10076)","CON","I","A","","CHINA","APAC1","",""
"10123","NATIONAL CHUNG CHENG UNIV (INACTIVE) (#10123)","CON","I","A","","TAIWAN","APAC1","",""
"10124","HONGIK UNIV (#10124)","CON","I","A","","KOREA","Lamer","",""
"10125","KOREA ELECTRIC POWER RESEARCH INSTITUTE - KEPRI (#10125)","CON","I","A","","KOREA","Lamer","",""
"10134","SOUTH CHINA UNIV OF TECH (#10134)","CON","I","A","","CHINA","APAC1","",""
"10135","UNIV DE CANTABRIA (#10135)","","I","A","","SPAIN","EUROPE PLUS","",""
"10146","GRIFFITH UNIV (#10146)","CON","I, K","A","","AUSTRALIA","APAC1","",""
"10158","BROWN UNIV (#10158)","","I,R","A","RI","UNITED STATES","Namer E","",""
"10165","WESTERN MICHIGAN UNIV (#10165)","","I, K","A","MI","UNITED STATES","Namer C","",""
"10167","PUKYONG UNIV1 (#10167)","CON","I","A","","KOREA","Lamer","",""

Now how can i find 10055, 10167,10024 & 10076 value from the file and remove them. Hope you understand...

First sed command removes just the given numbers from the csv file preserving the remaining line content. If you want to remove the whole line containing the numbers (10055, 10167,10024 & 10076) then try second command.

sed 's/10055//g' inputfile.csv > outfile
sed '/10055/d' inputfile.csv > outfile
awk -F, '$1!~/10(055|167|024|076)/' YourFile.csv

use nawk if on solaris

To have a more 'exact' matching, so that - for example - 100552 will not be matched when looking for 10055

awk -F, '$1!~/^"10(055|167|024|076)"$/' YourFile.csv