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 -- Posted via http://www.ruby-forum.com/.
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 Ricardito <ricardo.orozco@hp.com> 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. > > Thanks much, > > ricardo > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On 7/17/06, Ricardo Ricardito <ricardo.orozco@hp.com> 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 Chandler 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? > > ZackHi 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 -- Posted via http://www.ruby-forum.com/.
Peter Michaux wrote:> On 7/17/06, Ricardo Ricardito <ricardo.orozco@hp.com> 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. > > PeterHi 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. -- Posted via http://www.ruby-forum.com/.
Peter Michaux wrote:> On 7/17/06, Ricardo Ricardito <ricardo.orozco@hp.com> 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. > > PeterHi 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 -- Posted via http://www.ruby-forum.com/.
On 7/17/06, Ricardo Ricardito <ricardo.orozco@hp.com> 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 Development 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