>>333
一応できたので貼っておきます。
区切り文字は見にくいので、各コメントの前をタイトルにしました。
注意事項としてレースIDは前走のレースIDになります。
# -*- coding: Windows-31j -*-
in_folder = "C:\\コメント\\in\\"
temp_folder = "C:\\コメント\\temp\\"
out_file = "C:\\コメント\\out\\コメント.csv"
title1 = "■コメント ".force_encoding('ASCII-8BIT')
title2 = "■次走へのメモ ".force_encoding('ASCII-8BIT')
title3 = "■談話 ".force_encoding('ASCII-8BIT')
arry_raceid = Array.new
arry_raceid = ["08","09","07","10","05","06","03","04","01","02"] #場所コード変換(KOL→JRA−VAN)
outfile = open(out_file,"w")
Dir::foreach(in_folder){|infile|
next if /^kd3_mb[0-9][0-9][0-9][0-9][0-9][0-9]\.lzh$/ !~ infile
cmd1 = "del /q " + temp_folder + "\\*.*"
cmd2 = "lhact x " + in_folder + infile + " " + temp_folder
system(cmd1)
system(cmd2)
open(temp_folder + "kol_com1.kd3","r"){|file|
while line = file.gets
record = line.force_encoding('ASCII-8BIT')
raceid = record[12,8] + arry_raceid[record[0,2].to_i] + record[6,6] + record[70,2]
com1 = record[91,960].strip
com2 = record[1051,960].strip
com3 = record[2011,960].strip
rec = "RX" + raceid + ","
if com1 != "" then rec = rec + title1 + com1 end
if com2 != "" then rec = rec + title2 + com2 end
if com3 != "" then rec = rec + title3 + com3 end
outfile.puts(rec)
end
}
}
outfile.close