# Taking input

**URL:** <https://www.ruby-forum.com/t/taking-input/98710>\
**Category:** Rails\
**Created:** [July 17, 2006, 6:18pm UTC](https://www.ruby-forum.com/t/taking-input/98710 "2006-07-17T18:18:35Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ricardo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a6a055/32.png) [@ricardo](https://www.ruby-forum.com/u/ricardo)\
**Post date:** [July 17, 2006, 6:18pm UTC](https://www.ruby-forum.com/t/taking-input/98710/1 "2006-07-17T18:18:35Z")

</div>

Hi everybody, I’m pretty new with Ruby on Rails and I was hoping someone  
could help me out. I’m trying to take in data from a file and add it to  
my existing database. what I’m thinking is that I have to create a  
class that reads the data and copies it. I’m not sure how I will input  
the data into my database. I’m not sure if this approach is the best.  
I would really appreciate it if someone gives me some feedback.

Thanks much,

ricardo

---

<div class="post-metadata">

**Author:** ![ricardo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a6a055/32.png) [@ricardo](https://www.ruby-forum.com/u/ricardo)\
**Post date:** [July 17, 2006, 6:34pm UTC](https://www.ruby-forum.com/t/taking-input/98710/2 "2006-07-17T18:34:41Z")

</div>

Please give more info.  
Are you going to do this through a web app? If not, you could use plain  
ruby.  
What format is the data in? CSV? XML?

Zack

---

<div class="post-metadata">

**Author:** ![ricardo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a6a055/32.png) [@ricardo](https://www.ruby-forum.com/u/ricardo)\
**Post date:** [July 17, 2006, 6:38pm UTC](https://www.ruby-forum.com/t/taking-input/98710/3 "2006-07-17T18:38:28Z")

</div>

On 7/17/06, Ricardo R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi everybody, I’m pretty new with Ruby on Rails and I was hoping someone  
> could help me out. I’m trying to take in data from a file and add it to  
> my existing database. what I’m thinking is that I have to create a  
> class that reads the data and copies it. I’m not sure how I will input  
> the data into my database. I’m not sure if this approach is the best.  
> I would really appreciate it if someone gives me some feedback.

What format is your data file? YAML, comma-separated, etc? How much  
data?

It may be relatively easy to write a straight ruby script that reads  
the file and uses active record to load the data into the database.

Peter

---

<div class="post-metadata">

**Author:** ![ricardo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a6a055/32.png) [@ricardo](https://www.ruby-forum.com/u/ricardo)\
**Post date:** [July 17, 2006, 7:24pm UTC](https://www.ruby-forum.com/t/taking-input/98710/4 "2006-07-17T19:24:25Z")

</div>

Zack C. wrote:

> Please give more info.  
> Are you going to do this through a web app? If not, you could use plain  
> ruby.  
> What format is the data in? CSV? XML?
> 
> Zack

Hi Zack,

I’m going to do this through a web app. More specifically I will have  
the user enter a path to their file, read it, and export it to my  
database. The format of the file could be two: .rc (resource files for  
windows) or Nib (Mac files).

thanks again zack

ricardo

---

<div class="post-metadata">

**Author:** ![ricardo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a6a055/32.png) [@ricardo](https://www.ruby-forum.com/u/ricardo)\
**Post date:** [July 17, 2006, 7:32pm UTC](https://www.ruby-forum.com/t/taking-input/98710/5 "2006-07-17T19:32:36Z")

</div>

Peter M. wrote:

> On 7/17/06, Ricardo R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Hi everybody, I’m pretty new with Ruby on Rails and I was hoping someone  
> > could help me out. I’m trying to take in data from a file and add it to  
> > my existing database. what I’m thinking is that I have to create a  
> > class that reads the data and copies it. I’m not sure how I will input  
> > the data into my database. I’m not sure if this approach is the best.  
> > I would really appreciate it if someone gives me some feedback.
> 
> What format is your data file? YAML, comma-separated, etc? How much  
> data?
> 
> It may be relatively easy to write a straight ruby script that reads  
> the file and uses active record to load the data into the database.
> 
> Peter

Hi Peter,

The format of the files are either .rc (windows) or Localizable.strings  
(Mac). I’m not sure how much data I will be importing nonetheless, how  
will impact my database? I want to do this through a web app.

Thanks for taking the time Peter,

Ricardo

---

<div class="post-metadata">

**Author:** ![ricardo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a6a055/32.png) [@ricardo](https://www.ruby-forum.com/u/ricardo)\
**Post date:** [July 17, 2006, 7:27pm UTC](https://www.ruby-forum.com/t/taking-input/98710/6 "2006-07-17T19:27:29Z")

</div>

Peter M. wrote:

> On 7/17/06, Ricardo R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Hi everybody, I’m pretty new with Ruby on Rails and I was hoping someone  
> > could help me out. I’m trying to take in data from a file and add it to  
> > my existing database. what I’m thinking is that I have to create a  
> > class that reads the data and copies it. I’m not sure how I will input  
> > the data into my database. I’m not sure if this approach is the best.  
> > I would really appreciate it if someone gives me some feedback.
> 
> What format is your data file? YAML, comma-separated, etc? How much  
> data?
> 
> It may be relatively easy to write a straight ruby script that reads  
> the file and uses active record to load the data into the database.
> 
> Peter

Hi Peter,

The format of the files are either rc (resource files for windows) or  
Nib (files for Mac). I’m not sure how much data I will be importing  
nonetheless, how will impact my database? I want to do this through a  
web app.

---

<div class="post-metadata">

**Author:** ![ricardo](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/a6a055/32.png) [@ricardo](https://www.ruby-forum.com/u/ricardo)\
**Post date:** [July 17, 2006, 8:01pm UTC](https://www.ruby-forum.com/t/taking-input/98710/7 "2006-07-17T20:01:42Z")

</div>

On 7/17/06, Ricardo R. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> The format of the files are either .rc (windows) or Localizable.strings  
> (Mac).

I don’t know anything about those formats.

> I’m not sure how much data I will be importing nonetheless, how  
> will impact my database?

The amount won’t affect your database but if it was just a little bit  
of data it would affect how you get it into the database.

> I want to do this through a web app.

The user chooses the file and uploads it with a multi part form as  
explained in Agile Web D. with Rails 1st Ed. page 362. The  
action will receive the file as part of the params hash. You will then  
need to write some custom Ruby code in this controller that knows how  
to slice and dice the .rc or .nib file. Then do an active record  
create call for each record. This is the approach I would try.

Peter
