I have CSV file of words and their frequencies as well as a .txt file containing several words of interest, separated by newlines.
I'm looking for a way to check if, for every row of the CSV, the first column value (the word) is also in the .txt file.
I guess something similar to fgrep -x -f patternfile.txt data.csv
except with only 1 column of the CSV rather than the entire row?
Hey You can use FasterCSV to open and loop thru the records.
FasterCSV.foreach("#{file_path}") do |row|
puts row[0]#row[0] is the first column only
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With