So I have two files file.csv
and file2.txt
.
file1.csv
is of the following nature:
aaa,bbb,ccc,ddd
aab,bba,ccd,eee
fff,ggg,hhh,iii
jjj,kkk,lll,mmm
and file2.txt
is of the following nature:
aaa
jjj
So I wrote a piece of code, which finds if the contents of file2.txt exist in the first column of file1.csv and if the exist then delete the entire row.
Here is the command:
grep -ivf file2.txt file1.csv>output.csv
so after running this command i get the following outptut:
aab,bba,ccd,eee
fff,ggg,hhh,iii
what I am looking for is an alternate solution to this. I want to open file1.csv read the first column row by row(preferably load it into an array) compare it with file2.txt every time. My actual script si big and i dont want to create any temp files in between so ia m looking to load the contents of the first column of the file1 into an array then compare it with file2.txt and at the end dump the entire array into a csv file.