首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

数据导入部类来源

2012-11-03 
数据导入类型来源?# to change this template, choose tools | templates# and open the template in the

数据导入类型来源
    ?
# to change this template, choose tools | templates
# and open the template in the editor.
?
#puts "hello world"
str = file.read('d:/csvtest.txt')
valuefile = file.new('d:/orig.txt','w')
$stdout = valuefile
str.gsub!(/"|\+|\n/,'')
str.sub!(/select|select/,'')
#puts str
index = str.index(' where ')
#puts str[0..index]
str[index..-1] =''
arry = str.split(' from ')
colvalue = arry[0]
orivalue =arry[1]
value = []
value_hash = hash.new
while /\,/ =~ colvalue
? sign_index = colvalue.index(',')
? if colvalue[0..sign_index].count('(') == colvalue[0..sign_index].count(')')
?
? ? value << colvalue[0...sign_index].gsub('|',',')
? ? value[-1].gsub!("<span style="white-space: pre;"></span>",'')
? ? value[-1].gsub!(" ",'')
? ? colvalue[0..sign_index] = ''
? else
? ? colvalue[sign_index] = '|'
? end
end
value << colvalue
puts value
puts "____" *20
valuefile.close
$stdout =stdout
puts "fgi"
#puts arry[0]
#puts 'sdf' ?if "avagd".count('4') == 'aa'.count('a')
arry = orivalue.split(',')
for i in arry
? arry = i.split
? if arry.length == 2
? ? value_hash[arry[0]] = arry[1]
? ? # puts arry[1]
? end
end
finish = []
for i in value
? value_hash.each{|key,valueo|
?
? ? if /#{valueo}./ =~ i
? ? ? index = i.index("#{ valueo}\.")
? ? ? #puts index
? ? ? if index == 0
? ? ? ? puts i
? ? ? ? i[index..index + 1] = key
? ? ? ? finish << i
? ? ? ? #value.delete(i)
? ? ? ? # next
? ? ? ? # break
?
# ? ? ?else /\(/ =~ i[index - 1...index]
# ? ? ? ?puts i
# ? ? ? ?i[index..index + 1] = key
# ? ? ? ?finish << i
# ? ? ? ?value.delete(i)
? ? ? end
?
? ? end
?
? ? # puts "#{key}=>#{value}"
? }
end
?
puts finish
#valuefile.close
#$stdout =stdout
##puts value_hash
?
def ishasoname hash,value,finish
? hash.each{ |key,hash_vl|
? ? hash_vl ?= hash_vl.to_s
? ? hash_vl << '.'
? ? if index = value.index(hash_vl)
? ? ? if index == 0 or /\w/ =~ value[index - 1 ...index]
? ? ? ? value[index..index+1] = key
? ? ? ? puts value
? ? ? ? finish << value
?
? ? ? ? reuturn
? ? ? end
? ? end
?
? }
? puts value
? finish << value
? puts hash
end
 

热点排行