idx = keyss.index('i')
log_time = keyss[0..idx-2]
puts log_time.split(" ")[1][0..1]
require 'time'
#puts Time.parse(log_time)
lid = keyss.index('(')
rid = keyss.rindex(')')
keys = keyss[lid+1..rid-1].split(',')
valuess = mesg[1]
lidv = valuess.index('(')
ridv = valuess.rindex(')')
sqlStr = valuess[lidv+1..ridv-1]
values = Array.new
t = 0
index = 0
tt = ''
for i in 0..sqlStr.length-1
t1 = sqlStr[i]
if t1 == '\''
t = t + 1
end
if t1 == ',' && t % 2 == 0
values[index] = tt
index = index + 1
tt = ''
t = 0
next
end
tt = tt + t1
if i == sqlStr.length - 1
values[index] = tt
end
end
indexK = keys.size
indexV = values.size
for i in 0..keys.size
if keys[i] == 'time' then
puts values[i]
end
if keys[i] == 'province' then
puts 'province'+values[i]
end
if keys[i] == 'city' then
puts values[i]
end
if keys[i] == 'phone_number' then
puts values[i]
end
if keys[i] == 'longitude' then
puts values[i]
end
if keys[i] == 'latitude' then
puts values[i]
end
if keys[i] == 'test_place' then
puts values[i]
end
if keys[i] == 'connect_operator' then
puts 'connect_operator'+values[i]
end
if keys[i] == 'signal_strength' then
signal_strength = values[i].gsub("'","")
puts signal_strength.to_f
end
if keys[i] == 'net_type' then
puts 'net_type'+values[i]
end
if keys[i] == 'bandwidth' then
puts 'bandwidth'+values[i]
end
if keys[i] == 'success_rate' then
success_rate = values[i].gsub("'","")
puts success_rate.to_f
end
if keys[i] == 'ninety_loading' then
ninety_loading= values[i].gsub("'","")
puts ninety_loading.to_f
2 个回复
erha_erha - 90后程序员
赞同来自:
erha_erha - 90后程序员
赞同来自: