ruby - How to compare data in two CSV files -


i have 2 csv files have same structure , ideally should have same data.

i want compare data in them using ruby , wanted know if have ruby function same.

as summea commented, @ csv class.

then use:

#will store each line of each file array of fields (so array of arrays). file1_lines = csv.read("file1.csv") file2_lines = csv.read("file2.csv")  in 0..file1_lines.size   if (file1_lines[i] == file2_lines[i]     puts "same #{file1_lines[i]}"   else     puts "#{file1_lines[i]} != #{file2_lines[i]}"   end end 

note using for in ruby quite rare. iterate using each on collections, there 2 of them here.

also, pay attention 1 of list may longer other, should started.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -