Open MDB file on Ubuntu, convert it to CSV, import it to Rails

Open MDB file on Ubuntu, convert it to CSV, import it to Rails
MDB is a data file format used by Microsoft Office Access. To open and view MDB files on ubuntu, you can install a tools named mdbtools :

sudo apt-get install libmdbtools mdbtools mdbtools-gmdb

This will also install MDB viewer, and you can use it to open and view MDB files. It also can be used to export tables to CSV(Comma-separated_values) files.

And here is an example importing CSV data into Rails model:
require ‘csv’
CSV::Reader.parse(File.open(‘/path/to/file’, ‘rb’)).each do |row|
    Production.create(:name => row[1],
        :price => row[3])
end

转载请注明: 转自船长日志, 本文链接地址: http://www.cslog.cn/Content/csv/

相关日志:

  1. Ruby on Rails实战–创建一个网上商店E用户管理模块
  2. 用ruby语言以句子为单位拆分一个字串
  3. 我使用的android应用程序们
  4. REST and ActiveResource
  5. 半semantic, 数据的价值和数据显示
此条目发表在 Ruby on Rails, 信息处理 分类目录。将固定链接加入收藏夹。

发表评论

电子邮件地址不会被公开。 必填项已被标记为 *

*

您可以使用这些 HTML 标签和属性: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>