# Importing Large Data Sets into Rails App

**URL:** <https://www.ruby-forum.com/t/importing-large-data-sets-into-rails-app/119886>\
**Category:** Rails\
**Created:** [November 11, 2007, 10:47pm UTC](https://www.ruby-forum.com/t/importing-large-data-sets-into-rails-app/119886 "2007-11-11T22:47:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![michaelb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@michaelb](https://www.ruby-forum.com/u/michaelb)\
**Post date:** [November 11, 2007, 10:47pm UTC](https://www.ruby-forum.com/t/importing-large-data-sets-into-rails-app/119886/1 "2007-11-11T22:47:55Z")

</div>

I am building an app for a client that will require importing large  
amounts (~2GB) of zipcode-specific data from Excel files. I was just  
wondering what you folks thought the best solution for importing the  
data to the database would be? Currently I’m planning on converting  
the Excel data to .csv and writing a script that will load from an  
arbitrary number of .csv diles in a directory, but that will take  
hours to complete. Is there a better way?

Thanks,

Michael B.  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![michaelb](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/b19c9b/32.png) [@michaelb](https://www.ruby-forum.com/u/michaelb)\
**Post date:** [November 11, 2007, 10:53pm UTC](https://www.ruby-forum.com/t/importing-large-data-sets-into-rails-app/119886/2 "2007-11-11T22:53:13Z")

</div>

Well, you will not want to create an AR object for each row, because,  
like you said, that would take hours and hours. You should use the  
actual DB connection that AR gives you and do multiple inserts with  
straight SQL. If you are using MySQL the best way to load that amount  
of data would be to use the LOAD DATA directive. I’m sure most DB’s  
have similar functionality for loading large amounts of data all at  
once. If you are using MySQL read up on LOAD DATA because that is your  
best option.

-Ben
