I am very new to ruby and I want to check for rows with the same number in a csv file.
What I am trying to do is go through the input csv file and copy element from the input file to the output file also adding another column called "duplicate" to the output file, then check if a similar phone is already in the output file while copying data from input to output then if the phone already exist, add "dupl" to the row in the duplicate column.
This is what I have.
file=CSV.read('input_file.csv')
output_file=File.open("output2.csv","w")
for row in file
output_file.write(row)
output_file.write("\n")
end
output_file.close
Example:
| Phone |
|---|
| (202) 221-1323 |
| (201) 321-0243 |
| (202) 221-1323 |
| (310) 343-4923 |
output file
| Phone | Duplicate |
|---|---|
| (202) 221-1323 | |
| (201) 321-0243 | |
| (202) 221-1323 | dupl |
| (310) 343-4923 |