On Thu, Nov 10, 2011 at 20:23, Darren H. <dhulem1 / umbc.edu> wrote:

> require 'csv'
> CSV.foreach("c:\plantproducts.csv") do |row|
> puts row.join(",")
> end

Why do this?  It just joins together what CSV has put asunder.  Or are
you just looking for confirmation of the file contents?

> puts "enter Product ID Number"
> product_id = gets.chomp
> CSV.foreach("c:\plantproducts.csv") do |row|
> product_id == row[0]
> end

You're looping over the entire file... and only comparing to the
desired product_id.  The fact that you're continuing to look, after
you've found it, is just an efficiency issue, but mainly you're not
doing anything *based* on the result of that comparison.  This seems
to be the whole key to your question:

> my question is when the program is running and when you enter in your
> product id number as it matches in the csv file (such as 1001 and the
> price is 8.00) how do I get the other data from the csv file such as
> price so I can later use it and show to the program user)

You've still got the row array there.  All you've got to do is use it.
 Something like:

  CSV.foreach("c:\plantproducts.csv") do |row|
    if product_id == row[0]
      do something with row
      i also suggest you exit the loop
    end
  end

Exactly *what* you should do with row, and how to exit the loop, I'll
leave as exercises.

-Dave

-- 
LOOKING FOR WORK! What: Ruby (on/off Rails), Python, other modern languages.
Where: Northern Virginia, Washington DC (near Orange Line), and remote work.
See: davearonson.com (main) * codosaur.us (code) * dare2xl.com (excellence).
Specialization is for insects. (Heinlein) - Have Pun, Will Babble! (Aronson)