从目录导入CSV文件,以便在Rails上种数据库 [英] Import CSV Files from a directory in order to seed a database on Rails

查看:127
本文介绍了从目录导入CSV文件,以便在Rails上种数据库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从一些Excel文件中填入大量记录的数据库,但是我只会使用这些CSV文件,因为在播放数据库后,其他记录将从表单中输入。

I need to seed a database with a lot of records from some Excel files, but I will only use those CSV files once because after seeding the database the other records will be input from forms.

我的老板告诉我将CSV文件放在项目的目录中,然后从这些文件中获取记录到数据库。

My boss told me to put the CSV files in a directory in the project and then get the records from those files to the database.

I我使用MongoDB on Rails。

I'm using MongoDB on Rails.

我不想要完整的代码,只是一些引导与宝石,逻辑等。

I don't want the full code, just some guidance with gems, logic, etc.

推荐答案

如果是一次性导入,为什么不使用像这个好主意或MongoDB自己的工具, mongoimport (可以接受CSV)

If it's for a one-off import, why not use something like this nice gist or MongoDB's own tool, mongoimport (which can accept CSVs)

这篇关于从目录导入CSV文件,以便在Rails上种数据库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆