A
Askar Ka
Hello all!
Things I want to do:
1) merging 2 csv files
2) sorting new merged file
3) delete some columns from a new merged file
1st csv file1:
11101,3310000,IKANIKEISAIGANAIBAAI,NISHI-KU
SAITAMA-SHI,SAITAMA,0,0,0,0,0,0
11101,3310058,IIDA,NISHI-KU SAITAMA-SHI,SAITAMA,0,0,0,0,0,0
11101,3310068,IIDASHINDEN,NISHI-KU SAITAMA-SHI,SAITAMA,0,0,0,0,0,0
2nd csv file2:
12101,2600000,IKANIKEISAIGANAIBAAI,CHUO-KU CHIBA-SHI,CHIBA,0,0,0,0,0,0
12101,2600852,AOBACHO,CHUO-KU CHIBA-SHI,CHIBA,0,0,0,0,0,0
12101,2600804,AKAICHO,CHUO-KU CHIBA-SHI,CHIBA,0,0,0,0,0,0
The code below:
------------------------------------
require "fileutils"
FileUtils.cp("file1.csv", "file3.csv")
File.open("file3.csv", "a+")
File.open("file2.csv", "r") do |file|
file.each_line do |line|
puts line
end
end
------------------------------------
1st I made a copy of the 1st file, and then I try just to add the
content of the 2nd file. At the moment I can only print the content of
the 2nd file, but can't to add this the file3...
This a problem 1.
2nd is sorting - please advise me directions which I need read more...
Thanks in advance!
Things I want to do:
1) merging 2 csv files
2) sorting new merged file
3) delete some columns from a new merged file
1st csv file1:
11101,3310000,IKANIKEISAIGANAIBAAI,NISHI-KU
SAITAMA-SHI,SAITAMA,0,0,0,0,0,0
11101,3310058,IIDA,NISHI-KU SAITAMA-SHI,SAITAMA,0,0,0,0,0,0
11101,3310068,IIDASHINDEN,NISHI-KU SAITAMA-SHI,SAITAMA,0,0,0,0,0,0
2nd csv file2:
12101,2600000,IKANIKEISAIGANAIBAAI,CHUO-KU CHIBA-SHI,CHIBA,0,0,0,0,0,0
12101,2600852,AOBACHO,CHUO-KU CHIBA-SHI,CHIBA,0,0,0,0,0,0
12101,2600804,AKAICHO,CHUO-KU CHIBA-SHI,CHIBA,0,0,0,0,0,0
The code below:
------------------------------------
require "fileutils"
FileUtils.cp("file1.csv", "file3.csv")
File.open("file3.csv", "a+")
File.open("file2.csv", "r") do |file|
file.each_line do |line|
puts line
end
end
------------------------------------
1st I made a copy of the 1st file, and then I try just to add the
content of the 2nd file. At the moment I can only print the content of
the 2nd file, but can't to add this the file3...
2nd is sorting - please advise me directions which I need read more...
Thanks in advance!