标签:end its encoding file pen ext1 col des each
数据分析脚本:
filepath="request.log.2017-12-01-15" File.open("#{filepath}").each do |line| begin File.open("#{filepath}").each do |line| if ! line.valid_encoding? s = line.encode("UTF-16be", :invalid=>:replace, :replace=>"?").encode(‘UTF-8‘) line = s.gsub(/dr/i,‘med‘) end fields = line.split("\t") if fields.length <10 next end adx = fields[3] desc = fields[10] ext10 = fields[45] reqtype= ext10[‘reqtype‘] puts "#{adx}\t#{desc}\t#{reqtype}" end rescue SystemCallError puts "warn:: #{filepath} not exits!!" end
标签:end its encoding file pen ext1 col des each
原文地址:http://www.cnblogs.com/lavin/p/7976046.html