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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Memo Field Parsing 1

Status
Not open for further replies.

Scott24x7

Programmer
Jul 12, 2001
2,828
JP
All,
I have a memo field that has text entries of about 100 words that I need to "capture" each word, and put into a seperate field in a table. How can I "extract" each word, no matter what the length of the memo field is, and put each word into a seperate table?


Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Hi Scott

I suppose, if the memo field is not simply enormous, you could do a replace with the 'white space' characters (commas, colons, semi-colons, tabs and so forth) exchanging them for carriage return, linefeeds, and then import the whole sheebang into a table a bit like:

Code:
Select MyTable
StrtoFile(MyTextSplit(MyTable.MyMemo),"c:\temp\temptxt.txt")
Select MyWordList
Append from c:\temp\temptxt.txt SDF for !empty(MyWordField)

Function MyTextSplit
  Parameter MyString
  Private MyString,m.crlf
  m.crlf = chr(13)+chr(10)
  MyString = StrTran(MyString," ",m.crlf)
  MyString = StrTran(MyString,",",m.crlf)
  MyString = StrTran(MyString,":",m.crlf)
  MyString = StrTran(MyString,";",m.crlf)
  MyString = StrTran(MyString,chr(9),m.crlf)
  Return(MyString)

I'm not sure about the 'for !empty(MyWordField) bit - it might not be required and I'm not 100% sure it works with SDF imports!

You could alternatively, try and process the memo character by character, assemble into words based on the 'white space' breaks and then append one by one - which might give you a chance to report progress!



Regards

Griff
Keep [Smile]ing
 

Hi Scott,

The easiest way is to use GETWORDCOUNT() and GETWORDNUM().

Something like this:

Code:
lcText = <contents of the memo field>
SELECT <table into which you wish to place the words>
FOR lnI = 1 to GETWORDCOUNT(lcText)
  APPEND BLANK
  REPLACE Whatever WITH GETWORDNUM(lcText, lnI)
ENDFOR

JanBucek: You mentioned ALINES(). That will parse the memo into lines, not words.

Mike




__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike - ALINES() will parse anything as long as you give it the right parse characters. That said, I agree that for this job, the GETWORDx() functions are a better choice.

Tamar
 
Mike,
Stars to you! Thanks, simple and elegant, and exactly what I was after. Tamar, thanks for the lesson on ALINES() as well... have used it in the past, but did not know it would work that way.
Cheers!

Best Regards,
Scott

&quot;Everything should be made as simple as possible, and no simpler.&quot;[hammer]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top