adx-desc-adtype统计

数据分析脚本:

 

 
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

 

posted on 2017-12-04 10:50  iokde.com  阅读(185)  评论(0编辑  收藏  举报

导航