# coding: Shift_JIS
# 012345678901234567890
indata = [
"A001YAMADA 080",
"B001TANAKA 065",
"A010YAMAMOTO 079",
"B004UETA 049",
"C032ANDO 095",
"D002KOMATSU 060"
]
#抽出条件例1
# (Aクラス かつ 80点以上)または(Bクラス かつ 50点以上)または(Cクラス)を抽出
#include_prm= "(0,1,CH,EQ,"A",AND,14,3,ZD,GE,80),OR,(0,1,CH,EQ,"B",AND,14,3,ZD,GE,50),OR,(0,1,CH,EQ,"C")"
outdata = Array.new
indata.each{|s|
if (s[0,1] == "A" && s[14,3].to_i >= 80) ||
(s[0,1] == "B" && s[14,3].to_i >= 50) ||
(s[0,1] == "C")
outdata.push(s)
end
}
p outdata #=>["A001YAMADA 080", "B001TANAKA 065", "C032ANDOU 095"]
#抽出条件例2
# (Bクラス かつ 50点以上 かつ 名前1文字目が"T" ) または Cクラス を抽出
#include_prm= "(0,1,CH,EQ,"B",AND,14,3,ZD,GE,50,AND,4,1,CH,EQ,"T"),OR,(0,1,CH,EQ,"C")"
outdata = Array.new
indata.each{|s|
if (s[0,1] == "B" && s[14,3].to_i >= 50 && s[4,1] == "T") ||
(s[0,1] == "C")
outdata.push(s)
end
}
p outdata #=>["B001TANAKA 065", "C032ANDOU 095"]
#抽出条件例3
# (Aクラス または Bクラス) かつ 50点以上
#include_prm= "(0,1,CH,EQ,"A",OR,0,1,CH,EQ,"B"),AND,(14,3,ZD,GE,50)"
outdata = Array.new
indata.each{|s|
if (s[0,1] == "A" || s[0,1] == "B") && (s[14,3].to_i >= 50)
outdata.push(s)
end
}
p outdata #=>["A001YAMADA 080", "B001TANAKA 065", "A010YAMAMOTO 079"]
#抽出条件例4
# Aクラス
#include_prm= "0,1,CH,EQ,"A""
outdata = Array.new
indata.each{|s|
if s[0,1] == "A"
outdata.push(s)
end
}
p outdata #=>["A001YAMADA 080", "A010YAMAMOTO 079"]
IyBjb2Rpbmc6IFNoaWZ0X0pJUwoKCiMgICAgMDEyMzQ1Njc4OTAxMjM0NTY3ODkwC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