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!

separating data in a field seperated by commas

Status
Not open for further replies.

dougerstew

Programmer
May 30, 2003
54
0
0
US
Hi,

I have a text file with multiple one or two digit numbers separated by commas.

It could be that there are only 2 numbers to separate (easy), but could also be up to 12 numbers.

so the string might be
2,1 or
2,1,3,1 or
3,2,5,1,7,12 or
3,2,5,2,8,2,4,2,7,3,9,3

each of the numbers between commas can be one or two digits. I want to add the 1st, 3rd, 5th, etc numbers in the string.

Can someone help me automate this process?

Thanks,

Doug


 
actually, I just realized I need to add the 2nd, 4th, 6th, etc numbers together.
 
[ ]
See if anything in this thread will help:


mmerlinn


"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Steven Raymond
 
[ ]
Mike Yearwood

ALINES() is not available in FP 2.6.

mmerlinn


"We've found by experience that people who are careless and sloppy writers are usually also careless and sloppy at thinking and coding. Answering questions for careless and sloppy thinkers is not rewarding." - Eric Steven Raymond
 

I would do it like this:

Code:
CREATE TABLE MyNumbers ;
   (No1 N(2), No2 N(2), No3 N(2), No4 N(2), ;
    No5 N(2), No6 N(2), No7 N(2), No8 N(2), ;
    No9 N(2), No10 N(2), No11 N(2), No12 N(2))
APPEND FROM ("c:\MyDir\MyTextFile.txt") TYPE DELIMITED WITH ","

SELECT MyNumbers
SCAN
   Do_Whatever_You_Want_With_The_Numbers
ENDSCAN

 
Thanks for the help, everyone. The main thing I used was the AT() command, which I'd never used before.

It works for me now.

Doug
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top