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

  • Home
  • SEARCH
  • 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 6764621
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:36:56+00:00 2026-05-26T14:36:56+00:00

is there anyone who has had experience with csv’s and ruby. i am new

  • 0

is there anyone who has had experience with csv’s and ruby. i am new in it and am trying to make a program that uses a csv file to save names and passwords that are entered in by the user. i have read several other posts and threw in some of my own. but a bit of code that was left in had a grep method on the array i want to know if there is a replacement method that does something similar. now i need it to be able to search for the name in the csv then match the corresponding password and then check if the password matches if it does then you’ll gain access further.

    def enter_the_vault(path_to_csv)
    @names = []
    csv_contents = CSV.read(path_to_csv)
    csv_contents.shift
    csv_contents.each do |row|
     @names << row[0]
    end
    @names.each {|f| f.downcase! }
end

def search_for_user
  puts "Please enter your username: "
  usern = gets.chomp.downcase
  results = [@names.grep(/#{usern}/)]
  if results.each {|f| puts f}
    prompt
  else
    puts "user does not exist"
    prompt
  end
end

def prompt
  puts "Incorrect.. do you want to retry: (y/n)"
  answer = gets.chomp.downcase

  case answer
  when /^y/
  search_for_user
  when /^n/
   puts "Goodbye."
  exit
  else
  prompt
  end
end 
  • 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-26T14:36:56+00:00Added an answer on May 26, 2026 at 2:36 pm

    This sounds curiously like a homework problem (usernames and clear-text passwords in a CSV?), but for working with CSV files I would suggest the FasterCSV library. It is an external dependency in Ruby 1.8 but included in 1.9.

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

Sidebar

Related Questions

Is there anyone who has used or looked into using Jitterbit as well as
Is there anyone who has already tried to use the Microsoft Bing translator web
Is there anyone who knows this? I have been trying this for the last
is there anyone who makes use of the Microsoft Open XML SDK 2.0 for
Is there anyone who have encountered Processing Dirty Regions error in MyEclipse? Actually everytime
Is there anyone who knows how to destroy a javascript (jquery) function? I'm using
Anyone out there who knows what are the differences between BasicRenderEngine and LazyRenderEngine?
Does anyone out there have any experience programatically retreiving the lat/long from a GPS
A question for anyone who has used the Java library Mallet's SimpleTagger class for
Is there anyone developing mobile industrial/enterprise/ERP/Inventory type applications who really loves their development tools

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.