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 8234917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:38:20+00:00 2026-06-07T18:38:20+00:00

I wrote this rake task that enables me to read a csv file from

  • 0

I wrote this rake task that enables me to read a csv file from a file on the local filesystem of my app, but how do I tweak this to make it read a file from a url?

desc "This class will read a csv file and display its contents on the screen"

 task :read_csv => :environment do |t, args|
 require "csv"

 csv_text = File.read('someFile.csv')
 csv = CSV.parse(csv_text, :headers=>true)
 csv.each do |row|
   puts row
 end
end

Would appreciate if someone can help me with either the code or some current links. Most of the links Im finding are for previous versions of rails where FasterCSV was not part of ruby.

Thanks

  • 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-06-07T18:38:21+00:00Added an answer on June 7, 2026 at 6:38 pm

    What about using NET::HTTP?

    desc "This class will read a csv file from url and display its contents on the screen"
    
      task :read_csv => :environment do |t, args|
      require "csv"
      require 'net/http'
    
      uri = URI('http://www.xxx.ccc.xxx.ca/~xxx/xxx.csv')
      csv_text = Net::HTTP.get(uri)
      csv = CSV.parse(csv_text, :headers=>true)
      csv.each do |row|
        puts row
      end
    end
    

    That is just a little tweak for only getting it from an url and without https, but you got the idea, right? 🙂

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

Sidebar

Related Questions

I want to call a rake task from a cron job that stores remote
I'm trying to run an example task that I wrote. I've placed the file
I want to have a rake task that reads a HAML file and creates
I have rails application that connects to multiple databases. I wrote custom rake task
I have a Rakefile with a Rake task that I would normally call from
I wrote this code for zoom in/out . it works but even with one
I wrote this program: #include <stdio.h> /*Part B Write a program that: defines an
I wrote this class that draws a animated progress with a circle (it draws
I want to use a Rake task to cache my sitemap so that requests
I'm working on a rake task which imports from a JSON feed into an

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.