there is a dbf file , can i open it with ruby?
···
--
Posted via http://www.ruby-forum.com/.
there is a dbf file , can i open it with ruby?
--
Posted via http://www.ruby-forum.com/.
"Pen Ttt" <myocean135@yahoo.cn> wrote in message
news:39ae7de1fd20340c05bed8c0589a3d8b@ruby-forum.com...
there is a dbf file , can i open it with ruby?
--
Posted via http://www.ruby-forum.com/\.
Http://rubyforge.org has snippets for
- XBase/DBase Reader class
- XBase/DBase Writer class
HTH gfb
On 12.04.2010. 08:14, Pen Ttt wrote:
there is a dbf file , can i open it with ruby?
Depends.
If it's a dBase file, then use GitHub - infused/dbf: DBF is a small, fast Ruby library for reading dBase, xBase, Clipper, and FoxPro database files.
If it's a Mimer DB, then it's not possible ![]()
// Magnus Holm
On Mon, Apr 12, 2010 at 08:14, Pen Ttt <myocean135@yahoo.cn> wrote:
there is a dbf file , can i open it with ruby?
--
Posted via http://www.ruby-forum.com/\.
hai ,everyone
i have installed dbf,
gem install dbf
require 'dbf'
table = DBF::Table.new("/home/pt/test/sh.dbf")
# /home/pt/test/sh.dbf is my dbf file.
table.each do |record|
puts record
end
there is the output
#<DBF::Record:0x9e22cfc>
#<DBF::Record:0x9dbbdcc>
#<DBF::Record:0x9d90cf4>
#<DBF::Record:0x9cd53b4>
#<DBF::Record:0x9c07260>
#<DBF::Record:0x9a8faa0>
#<DBF::Record:0x993f2dc>
#<DBF::Record:0x96fd2c4>
#<DBF::Record:0xa22019c>
#<DBF::Record:0xa19e6fc>
#<DBF::Record:0xa185888>
#<DBF::Record:0xa174590>
#<DBF::Record:0xa124404>
#<DBF::Record:0xa0d1d64>
#<DBF::Record:0xa089364>
#<DBF::Record:0x9fdb688>
#<DBF::Record:0x9f6cd64>
#<DBF::Record:0x9f0ca98>
#<DBF::Record:0x9ef7344>
#<DBF::Record:0x9ea89e4>
#<DBF::Record:0x9e0c038>
#<DBF::Record:0x9d9faf4>
#<DBF::Record:0x9d2c524>
#<DBF::Record:0x9cd204c>
#<DBF::Record:0x9c002b4>
#<DBF::Record:0x99e0560>
#<DBF::Record:0x98b1f48>
#<DBF::Record:0x967a90c>
=> 0
many many
1\how can i know how many fields in the dbf (/home/pt/test/sh.dbf )?
--
Posted via http://www.ruby-forum.com/.
i haved solved this problem myself
1、to get schema in ubuntu console:
pt@pt-laptop:~$ dbf -a /home/pt/test/sh.dbf
2、to get csv file in ubuntu console:
dbf -c /home/pt/test/sh.dbf
there is a file named /home/pt/sh.csv
everything is ok.
--
Posted via http://www.ruby-forum.com/.
hi ,here is my programm:
require 'iconv'
require 'dbf'
table = DBF::Table.new("/home/pt/test/shbase.dbf")
table.each do |record|
print
Iconv.iconv('UTF-8','GBK',record.stock_name),",",record.stock_code,"\n"
end
the output is:
["工商银行"],601398
["吉林高速"],601518
["北辰实业"],601588
["中国铝业"],601600
["中国太保"],601601
["上海医药"],601607
what i want to get is:
工商银行,601398
吉林高速,601518
北辰实业,601588
中国铝业,601600
中国太保,601601
上海医药,601607
how can i get it?
--
Posted via http://www.ruby-forum.com/.