Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
ONE FOR THE EXPERTS - Appending lines with different for
Message
From
28/05/1998 21:27:44
Jp Steffen
Leadership Data Services
Des Moines, Iowa, United States
 
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00098397
Message ID:
00102964
Views:
52
>Howdy from Nashville!
>
>Forgive me if this is a "newbie" question, but...
>
>I have an SDF file that I must append into a set of tables. Every line in the file can have a different layout and length depending on what kind of record it is. The kind of record is determined by the first character of the line.
>
>Here is the basic situation:
>
>INCOMING.SDF can have different layouts on a line by line basis, so I need to be able to look at the first character of an entire line, then append the entire line into a set of tables, like so:
>
>Line Layout 1 --> Table1.dbf (which just holds Layout 1 records)
>Line Layout 2 --> Table2.dbf (etc.)
>Line Layout 3 --> Table3.dbf
>Line Layout 4 --> Table4.dbf
>Line Layout 5 --> Table5.dbf
>Line Layout 6 --> Table6.dbf
>
>I thought about appending the entire file, line by line, into 1 MEMO field (since these lines have over 254 character lengths) in a temporary database, then APPENDing from the temp table into my other DBFs based on left(MEMOFIELD,1).
>
>USE MEMOFILE IN 0
>APPEND FROM SDFFile.txt TYPE SDF
>USE
>
>USE Table1 in 0
>APPEND FROM (MEMOFILE's MEMO field) FOR left(MEMOFIELD,1) = "3"
>etc., etc.
>
>Alas, FoxPro 3 didn't like the idea of appending an entire line into a memo field, giving me an error message of "No fields found to process." Sigh.
>
>Can anyone give me an idea as to how I should approach this wacked out file?
>
>Thanks so much,

John - I have been away from the thread for quite awhile but your question caught my eye as I have a very similar application which must populate several different .dbfs from a delimited files with 7 different file types and formats.

I have created a dictionary table that contains a record for each different file type to be found in the delimited file. Each dictionary record has a memo field in which I have stored the format for that particular record type. I use AFIELDS to store the structure to an array and then SAVE TO to store the array in a memo field in my dictionary file.

In order to create and populate a cursor with the correct structure for each file type I pass the name of my delimited file to the following function. I use 'lafiles' (an array) to return information about the populated cursors and 'lctype' to select from among a group of possible transfer formats. CXFRMT is the field in my dictionary file which has the 'set' name I use to select from among a number of possible transfer types. So I can not only create a unique structure for each file types but also select a set of appropriate file types depending on the type of transfer I am receiving.

FUNCTION XFRPROC
LPARAMETERS lcXfile, laFiles, lcType

SELECT XFERDICT
lnCnt = 0
SCAN FOR CXFRMT = ALLTRIM(lcType)
lnCnt = lnCnt + 1
DIMENSION laFiles[lnCnt]
lcFileName = UPPER(ALLTRIM(rtype))
laFiles[lnCnt] = lcFileName
RESTORE FROM MEMO RFORMAT ADDITIVE
CREATE CURSOR (lcFileName) FROM ARRAY LASTRUC
ENDSCAN

FOR i = 1 to lnCnt
SELECT (laFiles[i])
APPEND FROM (lcXfile) FOR RTYPE = laFiles[i] DELIMITED WITH |
NEXT

RETURN lnCnt
Previous
Reply
Map
View

Click here to load this message in the networking platform