1 Replies - 2329 Views - Last Post: 06 December 2010 - 08:47 AM Rate Topic: -----

#1 gopnh  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 29-October 10

Search csv file for input value

Posted 06 December 2010 - 07:43 AM

I am new at java and need help fiquring out how to search a csv file to validate an input value.

I am getting the the user input OK. I want to be able to validate that this is a valid part number before continuing, so would like to search and excel spreadsheet to see if indeed the part number is valid, and return a true value or else return "Invalid part number, please reenter.
Is This A Good Question/Topic? 0
  • +

Replies To: Search csv file for input value

#2 DaneAU  Icon User is offline

  • Great::Southern::Land
  • member icon

Reputation: 286
  • View blog
  • Posts: 1,619
  • Joined: 15-May 08

Re: Search csv file for input value

Posted 06 December 2010 - 08:47 AM

Does your spreadsheet only contain data for the part number ? If so then you can simply use import java.util.Scanner; to read in the file and check it against those contained within, if your .csv has more than just the part number then StringTokenizer will come in handy to break each entry / line into individual tokens.

For example say you have a .csv file with the following



You would know the first line is the column descriptions and from then on the first is the part number and the second is the price, you can use a delimeter "," to break up each line. This little example was created in OpenOffice so yours may vary; the same principles apply.

This post has been edited by DaneAU: 06 December 2010 - 08:54 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1