Split Large Text Field into several smaller fields
Mike Schwartz
mschw at athenet.net
Thu Jan 3 14:12:00 PST 2008
> Does anyone have a couple of lines of code to take a 200 character
> description field (I imported it from a customer supplied text file)
> and
> break it up into (4) 54 character description fields [snip]
>
> Scott Walker
Parsing routines are fairly simple to write in only a few lines. Build
a loop and use the "mid" function with some variable counters like LE and LF
in the sample below, using "INSTR" to search for spaces. Loop through the
"mid" 200 times and capture the characters.
They are so simple that I don't maintain a library of parses I've
written, but I can send you a sample of an address parsing routine, if you
would like. Here is some rough code to get you started:
15 ------- - - - - - - - - - - - - - - - -
ParsFld If: 'Translate some unexceptable characters to
spaces
Then: le=xlate(le,"!#$%&'<>*+,-./@:;?][{}()|~","
16 ------- - - - - - - - - - - - - - - - -
If: 'Parse LE into tokens...
Then: lf(2,.0)=instr(le," "); lg(25,*)=mid(le,"1",lf-"1")
Add lg to your string of 54 characters here. Then put some code like this
at the end of the loop, being careful not to read past the end of your 200
character string.
31 ------- - - - - - - - - - - - - - - - -
nxtTok If: 'Parse next token out of LE
Then: li=mid(le,lf+"1",len(le)-lf+"1"); le=li
32 ------- - - - - - - - - - - - - - - - -
If: lh="99" 'Limit of 99 Soundex tokens per
customer...
Then: goto ParsEnd 'Abort processing this cust address.
33 ------- - - - - - - - - - - - - - - - -
If: le eq "" 'No more tokens in string LE
Then: return
34 ------- - - - - - - - - - - - - - - - -
If:
Then: Goto ParsFld 'Parse next token
Mike Schwartz
More information about the Filepro-list
mailing list