We had a file format that was coming from a mainframe where it was impossibly long line, but the first two characters told the line type. We knew the line wasn't more than 2000 characters long including the delimiters. We came up with this approach and it works blazingly fast with VFP.
Step 1: Create a temporary cursor for the entire contents of the file. Basically get it into VFP as quick as we can. CREATE CURSOR MyTempFile ( cType C(2), Field01 C(200), Field02 C(200), Field03 C(200), Field04 C(200), Field05 C(200), Field06 C(200), Field07 C(200), Field08 C(200), Field09 C(200), Field10 C(200))
Step 2: Append into MyTempFile from file DATFile.txt
Step 3: Select the records out of the MyTempFile based on the cType which tells us what the structure is expected to be. This might fit your scenario where a certain field in the delimeter "means" something. You only need to handle the scenario where a delimiter spans from one field to another. Example solution?: SCAN SCATTER NAME oRec cFullField = oRec.Field01 + oRec.Field02 + oRec.Field03 + oRec.Field04 + oRec.Field05 + oRec.Field06 + oRec.Field07 + oRec.Field08 + oRec.Field09 + oRec.Field10 SELECT CASE CASE oRec.cType = "X2" SELECT TableX2 SCATTER NAME oRec BLANK oRec.Fld01 = STREXTRACT(cFulLField, "|", "|", 1) oRec.Fld02 = STREXTRACT(cFulLField, "|", "|", 2) oRec.Fld03 = STREXTRACT(cFulLField, "|", "|", 3) && Might be a memo field INSERT INTO TableX2 FROM NAME oRec CASE oRec.cType = "TY" && do something OTHERWISE && Unhandled situation ENDCASE Endscan
Hope this helps!
-----Original Message----- From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Matt Wiedeman Sent: Thursday, April 20, 2017 10:58 AM To: profox@leafe.com Subject: Text file import
Hello everyone,
I need to setup a job to import a pipe delimited text file. This is easy enough but one of the fields is larger than 254 characters. If I use a memo field, it does not import that field. I started to setup a routine to step through each character and store the fields manually but I would rather not do it that way.
Does anyone have a function or tip they can share to resolve this situation?
[excessive quoting removed by server]