Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 867593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:00:07+00:00 2026-05-15T10:00:07+00:00

I have a simple 4-column Excel spreadsheet that matches universities to their ID codes

  • 0

I have a simple 4-column Excel spreadsheet that matches universities to their ID codes for lookup purposes. The file is pretty big (300k).

I need to come up with a way to turn this data into a populated table in my Rails app. The catch is that this is a document that is updated now and then, so it can’t just be a one-time solution. Ideally, it would be some sort of ruby script that would read the file and create the entries automatically so that when we get emailed a new version, we can just update it automatically. I’m on Heroku if that matters at all.

How can I accomplish something like this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T10:00:08+00:00Added an answer on May 15, 2026 at 10:00 am

    If you can, save the spreadsheet as CSV, there’s much better gems for parsing CSV files than for parsing excel spreadsheets. I found an effective way of handling this kind of problem is to make a rake task that reads the CSV file and creates all the records as appropriate.

    So for example, here’s how to read all the lines from a file using the old, but still effective FasterCSV gem

    data = FasterCSV.read('lib/tasks/data.csv')
    columns = data.remove(0)
    unique_column_index = -1#The index of a column that's always unique per row in the spreadsheet
    data.each do | row |
      r = Record.find_or_initialize_by_unique_column(row[unique_column_index])
      columns.each_with_index do | index, column_name |
        r[column_name] = row[index]
      end
      r.save! rescue => e Rails.logger.error("Failed to save #{r.inspect}")
    end
    

    It does kinda rely on you having a unique column in the original spreadsheet to go off though.

    If you put that into a rake task, you can then wire it into you’re Capistrano deploy script, so it’ll be run every time you deploy. the find_or_initialize should ensure you shouldn’t get duplicate records.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Excel spreadsheet of some product data, (just a simple table) that
I have a simple 2-column layout with a footer that clears both the right
I have a simple event handler with a ItemAdding event that changes a column
I have a simple Excel speadsheet where in one column i write string values.
I have a pretty simple LIKE search for MySQL that i'd like to transform
This is different than the simple 2 column layout. I need to have this
Should simple JavaBeans that have only simple getters and setters be unit tested?? What
Hi I have a file that consists of too many columns to open in
I have simple one column HTML files ( ebooks from Gutenberg Project). I want
I have a basic excel spreadsheet like this: A B C D etc.. 10%

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.