Taking input

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

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

On 7/17/06, Ricardo R. [email protected] 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

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

Peter M. wrote:

On 7/17/06, Ricardo R. [email protected] 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

Peter M. wrote:

On 7/17/06, Ricardo R. [email protected] 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.

On 7/17/06, Ricardo R. [email protected] 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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs