when i run p1 ,i can get something like:
Zimmer Holdings, Inc.
Zion Oil & Gas Inc
Zions Bancorporation
Zions Bancorporation
Zions Bancorporation
Zions Bancorporation
Zweig Fund, Inc. (The)
Zweig Total Return Fund, Inc. (The)
p1:
require 'rubygems'
require 'mysql'
file=open('/home/pt/usastock/nasdaqcompanylist.csv','r')
dbh = Mysql.real_connect("localhost", "root", "*****", "usastock")
while line=file.gets
line=line.chomp.split("\"")
print line[3],"\n"
end
when i run p2,i can get nothing ,what's wrong?
p2:
require 'rubygems'
require 'mysql'
file=open('/home/pt/usastock/nasdaqcompanylist.csv','r')
dbh = Mysql.real_connect("localhost", "root", "*****", "usastock")
while line=file.gets
line=line.chomp.split("\"")
print line[3],"\n"
sqlstr="insert into nasdaqname(name) values (?);"
st=dbh.prepare(sqlstr)
st.execute(#{line[3]})
end
···
--
Posted via http://www.ruby-forum.com/.