From: Pen Ttt on 12 Apr 2010 07:06 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/.
From: Pen Ttt on 12 Apr 2010 07:34 i haved solved this problem myself 1、to get schema in ubuntu console: pt(a)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/.
From: Pen Ttt on 12 Apr 2010 20:09 hi ,here is my programm: require 'iconv' require 'dbf' table = DBF::Table.new("/home/pt/test/shbase.dbf") table.each do |record| 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/.
|
Pages: 1 Prev: how to open dbf file with ruby? Next: Multiple PeopleSoft Technofunctional requirements |