Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Detecting a string value as a number or text 1

Status
Not open for further replies.

PureSoft

Programmer
Aug 12, 2002
24
0
0
GB
Hi guys,

I'm sure this should be an easy one for you, although I couldn't find an example in some searches on the forum.

I have a csv file (from a shopping cart export) I've split up and read into an array holding these values as strings. What I want to do now is test some of them to see if its a number string (product prices) or just text (product descriptions). The reason why I need to test for them is that the csv has a varying number of product description fields, depending on the number of additional product options it has, before the price is given in the csv file.

So I want to search the successive string array elements, starting at the first product description field, until I find the price field (number to 2 decimal places) and then I'll know where I am for the rest of the structure of the CSV, which doesn't vary after that.

I couldn't find a specific string function to do this, I'm thinking there must be some simple type testing available, or is it the fact that I've stored it as a string meant that I need to do some sort of manual test, charatcer by character?

Thanks for your help and advise.

Philip.
 
There is an isnumeric() function that can evaluate a string to see if it is in fact numeric - hopefully this will help.
 
Thanks Tom,

That does the trick!

Philip
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top