Results 1 to 3 of 3
  1. #1
    Join Date
    May 2013
    Posts
    3

    Unanswered: Extracting a portion of text from a text file

    Hello every one ive got a request for some help im sort of a noob and im sure this is pretty simple. but i have many text files that i need to call a specific one/open it, extract a portion of the text based on a field in a form.....then import the text to a Memo field on that form with the press of a button then with the press of another button use that data for printing purposes i can figure all the bells and whistles out i just cant wrap my brain around the extraction portion. here is a sample of the text. i need to search for 1Z E98 953 03 0060 8714 and extract all the text to the proceeding ^XA^CI13 and the following ^XZ~SD20 if its any help this is a UPS label formatted in ZPL for printing on a Zebra printer. any snippits of code or explanation will be of great help...Thanks in advance :

    ^BY3,,203^FT156,979^BCN,,N^FD>:1ZE9>58953030060867 0^FS
    ^FT10,1038^A0N,24,24^FDBILLING: P/P^FS
    ^FT10,1063^A0N,24,24^FDREF1: 9553327150^FS
    ^FT544,1204^A0N,20,20^FDCUU 11.1 Z140 39.5V 04/2013^FS
    ^FT20,1189^A0N,25,25^FD^FO0,1265 ^GB1200,0,1^FS^FO0,1425 ^GB1200,0,1^FS^FT15,1300 ^A0N,35,35^FDPO : 9553327150^FS^FT420,1300 ^A0N,30,30^FDSHIP DATE: May 09, 2013^FS^FT15,1340 ^A0N,35,35^FDSO : 184266279^FS^FT600,1340 ^A0N,25,25^FDICN : 20836311^FS^FT420,1340 ^A0N,25,25^FDWAVE : 96795^FS^FT15,1380 ^A0N,35,35^FDDPCI: 550091116^FS^FT420,1380 ^A0N,30,30^FDQTY : 6^FS^FT15,1420 ^A0N,35,35^FDITEM: 84190^FS^FT300,1420 ^A0N,22,22^FD SKYLANDERS SA CHARACTER PACK ASSORTMENT (6 COUNT)^FS^FT100,1580 ^A0N,30,30^FD^BY4^BCN,140,N,N^FD>;0020020626020385 6040^FS^FT275,1610 ^A0N,30,30^FD00200206260203856040^FS^FT600,1380 ^A0N,25,25^FDSID : 40551238^FS^FS
    ^XZ~SD20
    ^XA^CI13
    ^LH0,0^FS
    ^PR4,4,2^FS
    ^FT0,1016^GB809,0,20^FS
    ^FT0,758^GB809,0,2^FS
    ^FT0,656^GB809,0,20^FS
    ^FT244,636^GB0,215,2^FS
    ^FT0,421^GB809,0,2^FS
    ^FT20,34^A0N,20,20^FDDISTRIBUTION^FS
    ^FT20,58^A0N,20,20^FD(559) 4974300^FS
    ^FT20,82^A0N,20,20^FDACTIVISION BLIZZARD FDC^FS
    ^FT20,107^A0N,20,20^FD4247 SOUTH MINNEWAWA^FS
    ^FT20,131^A0N,20,20^FDFRESNO CA 93725^FS
    ^FT406,51^A0N,40,40^FD2 LBS^FS
    ^FT630,51^A0N,30,30^FD3 OF 8^FS
    ^FT20,219^A0N,30,30^FDSHIP^FS
    ^FT20,260^A0N,30,30^FD TO:^FS
    ^FT122,205^A0N,30,30^FD(559) 4974300^FS
    ^FT122,238^A0N,30,30^FDWALMART STORES INC.^FS
    ^FT122,270^A0N,30,30^FD891 ROUTE 9^FS
    ^FT122,303^A0N,30,30^FDWALMART STORE 2116^FS
    ^FT122,345^A0N,40,40^FDQUEENSBURY NY 12804^FS
    ^FT20,630^BD2^FH^FD003840128040000[)>_1E01_1D961Z00608714_1DUPSN_1DE98953_1E07P3_1DD Q HG9D_1CO*TS+OH4D:9W2L+7GIET2+UG"HWOJ3%H(J_0D_1E_04 ^FS
    ^FT284,496^A0N,71,71^FD NY 128 001^FS
    ^BY4,,102^FT375,620^BCN,,N^FD>;42012804^FS
    ^FT20,711^A0N,50,50^FDUPS GROUND^FS
    ^FT20,740^A0N,25,25^FDTRACKING #: 1Z E98 953 03 0060 8714^FS
    ^FT687,756^GB122,0,100^FS
    ^BY3,,203^FT156,979^BCN,,N^FD>:1ZE9>58953030060871 4^FS
    ^FT10,1038^A0N,24,24^FDBILLING: P/P^FS
    ^FT10,1063^A0N,24,24^FDREF1: 9553327150^FS
    ^FT544,1204^A0N,20,20^FDCUU 11.1 Z140 39.5V 04/2013^FS
    ^FT20,1189^A0N,25,25^FD^FO0,1265 ^GB1200,0,1^FS^FO0,1425 ^GB1200,0,1^FS^FT15,1300 ^A0N,35,35^FDPO : 9553327150^FS^FT420,1300 ^A0N,30,30^FDSHIP DATE: May 09, 2013^FS^FT15,1340 ^A0N,35,35^FDSO : 184266126^FS^FT600,1340 ^A0N,25,25^FDICN : 20835563^FS^FT420,1340 ^A0N,25,25^FDWAVE : 96795^FS^FT15,1380 ^A0N,35,35^FDDPCI: 550091116^FS^FT420,1380 ^A0N,30,30^FDQTY : 6^FS^FT15,1420 ^A0N,35,35^FDITEM: 84190^FS^FT300,1420 ^A0N,22,22^FD SKYLANDERS SA CHARACTER PACK ASSORTMENT (6 COUNT)^FS^FT100,1580 ^A0N,30,30^FD^BY4^BCN,140,N,N^FD>;0020020626020384 8328^FS^FT275,1610 ^A0N,30,30^FD00200206260203848328^FS^FT600,1380 ^A0N,25,25^FDSID : 40551085^FS^FS
    ^XZ~SD20
    ^XA^CI13
    ^LH0,0^FS
    ^PR4,4,2^FS
    ^FT0,1016^GB809,0,20^FS
    ^FT0,758^GB809,0,2^FS
    ^FT0,656^GB809,0,20^FS
    ^FT244,636^GB0,215,2^FS

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    so ^XA^CI13 is the start of the data you are interested in
    and ^XZ~SD20 is the end of the data block

    what I'd be tempted to do is create a separate table for the shipping data with a one to one or one to many relationship to your orders
    I'd then import the whole file as a batch process.. as soon as it arrives. then you have all the data in the system, users can match whatever they need to howe you store the data is upto you but I'd probably start with the column '1Z E98 953 03 0060 8714' as the primary key (or if not a unique key) and the whole data stream between ^XA^CI13 and ^XZ~SD20 in a memo column. when a user matches they add the pk of the order to that shipping record. that way round yuou cna have multiple shipping records per order.

    the file import process should scan through the file line by line
    start processing at the first ^XA^CI13, then look for FDTRACKING #: in that data stream to get your tracking number, then add that data block + tracking number to the new table.

    the advantage of this approach
    you can have multiple people processing the shipping advice. you can monitor which shipping notes haven't been associated with no order.
    another advantage is that you can control the ownership of hte data. it doenst' need to be in a public area, there is less risk of data loss if sopmeone inadvertantly deletes the file.

    Im assumign you are up to speed with file handling
    use the left fucntion to detect the satrt/end of the data block
    use instr to see if FDTRACKING #: is presnet on that line
    used the mid function to return the tracking number


    heck if your order reference is embedded in the data stream I'd also grab that and do whatever you need to do
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    May 2013
    Posts
    3
    Quote Originally Posted by healdem View Post
    so ^XA^CI13 is the start of the data you are interested in
    and ^XZ~SD20 is the end of the data block

    what I'd be tempted to do is create a separate table for the shipping data with a one to one or one to many relationship to your orders
    I'd then import the whole file as a batch process.. as soon as it arrives. then you have all the data in the system, users can match whatever they need to howe you store the data is upto you but I'd probably start with the column '1Z E98 953 03 0060 8714' as the primary key (or if not a unique key) and the whole data stream between ^XA^CI13 and ^XZ~SD20 in a memo column. when a user matches they add the pk of the order to that shipping record. that way round yuou cna have multiple shipping records per order.

    the file import process should scan through the file line by line
    start processing at the first ^XA^CI13, then look for FDTRACKING #: in that data stream to get your tracking number, then add that data block + tracking number to the new table.

    the advantage of this approach
    you can have multiple people processing the shipping advice. you can monitor which shipping notes haven't been associated with no order.
    another advantage is that you can control the ownership of hte data. it doenst' need to be in a public area, there is less risk of data loss if sopmeone inadvertantly deletes the file.

    Im assumign you are up to speed with file handling
    use the left fucntion to detect the satrt/end of the data block
    use instr to see if FDTRACKING #: is presnet on that line
    used the mid function to return the tracking number


    heck if your order reference is embedded in the data stream I'd also grab that and do whatever you need to do
    thank you Healdem sorry it has taken some time to get back to you. You helped me alot ive almost got it up and rolling once again thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •