Skip to content

Instantly share code, notes, and snippets.

@Seasons7
Created July 1, 2009 18:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Seasons7/138950 to your computer and use it in GitHub Desktop.
Save Seasons7/138950 to your computer and use it in GitHub Desktop.
# --------------------------------------------------------------------------
# 拡張子の異なる同じファイル名の内容を検査
# "*"はコメント扱い
#
# 例) HogeHoge.csv HogeHoge.csv2
#
# --------------------------------------------------------------------------
$KCODE = "S"
require 'pp'
TARGET_EXTTYPE = "csv"
TARGET_EXTTYPE2 = "csv2"
tgtfiles = Dir.glob( "*." + TARGET_EXTTYPE )
tgtfiles2 = Dir.glob( "*." + TARGET_EXTTYPE2 )
tgtpair = []
tgtfiles.each do |filename|
filename2 = filename.gsub(/#{TARGET_EXTTYPE}/,TARGET_EXTTYPE2)
tgtpair << [filename,filename2] if tgtfiles2.include?( filename2 )
end
ok = 0
tgtpair.each do |fnames|
f1 = open(fnames[0],"r").readlines.delete_if{|line| line =~ /\*.+/ }
f2 = open(fnames[1],"r").readlines.delete_if{|line| line =~ /\*.+/ }
result = f1 - f2
unless result.empty?
print "\n*********> Compare Failed!! #{fnames[0]}\n"
else
print "."
ok += 1
end
end
print "\n"
print "----------------------------------------------\n"
print "Same is [#{ok}]\n"
print "----------------------------------------------\n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment