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

Muti Line address text files

Status
Not open for further replies.

acess

Technical User
Apr 28, 2001
5
US
I have a need to import printer output files into VFP and export as a Delimited file.
Printer output files can be four or five lines.

Sample File Four line

89832
Mr wiliams
4558 main ST
detroit mi 48021

Five line file

489349
Mr R Williams
ABC Tooling
4564 Main
Detroit MI 48021

I can not get the these files into VFP correctly.
Any ideas would be helpful.

 
Acess,
I notice a commonality that might help. This is a little tricky, but has worked for me before, others may have a better solution, but here's mine:

Create a table (free table is fine) with the following structure:

Tablename: ImportAddr
Field1: Data C80

That's should cover the longest line you have. (Probably overkill, but you'll want that for this one).

Now, the commonality is that you have a numeric field with some leading spaces. It looks like you could have 4 or 5, but let's say you've always got 3, and none of the other lines have spaces as leading characters (or at least not 3 of them.) That is your trigger. When you see 3 leading spaces, you know you have a new record. Now, I assume you are okay to keep the name as one item, but you can parse each as you need now. Do something like this:

USE IMPORTADDR
ZAP
APPEND FROM <myImportFile.txt> SDF
GO TOP
DO WHILE NOT EOF()
lnCount = 1
lnCurRec = RECNO()
SKIP
DO WHILE LEFT(DATA,3) # ' '
lnCount = lnCount +1
SKIP
ENDDO
GO lnCurRec && Go back to start of this address rec.
* At this point, we now know whether we're dealing with 4 or 5 lines for address. Also, I'll assume that we don't need to parse the lines beyond one field, but you can do that if you need to.
SELECT <TableToUpdate>
APPEND BLANK && I assume you want to create this record
SELECT IMPORTADDR
REPLACE TableToUpdate.CodeValue WITH IMPORTADDR.DATA
SKIP
REPLACE TableToUpdate.NameValue WITH IMPORTADDR.DATA
SKIP
REPLACE TableToUpdate.Addr1Value WITH IMPORTADDR.DATA
SKIP
IF lnCount = 5
REPLACE TableToUpdate.Addr2Value WITH IMPORTADDR.DATA
SKIP
ENDIF
REPLACE TableToUpdate.CityStateZip WITH IMPORTADDR.DATA
SKIP
ENDDO
*
You may need to tweek this a bit to get your desired results, but this should set you well on your way.
Best Regards,
Scott

&quot;Everything should be made as simple as possible, and no simpler.&quot;[hammer]
 
Scott thanks for the reply. With a few modifcations it worked fine

Bob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top