Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
COPY TO file TYPE DELIMITED
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00465753
Message ID:
00466466
Vues:
10
Finaly, after testing several methods to generate one ASCII file from 3 different sources, only one method was fast enough to be useful in my application.

The first method was intensively using the integrated Foxpro Command "COPY TO file TYPE DELIMITED"
DO WHILE as needed from the source tables
   SELECT SQL for the partial info I need in Table1
   COPY TO Text1 TYPE DELIMTED

   SELECT SQL for the partial info I need in Table2
   COPY TO Text2 TYPE DELIMTED

   SELECT SQL for the partial info I need in Table3
   COPY TO Text3 TYPE DELIMTED

   Append the 3 files in a memo field IN IMPORT
ENDDO
CLOSE DATA ALL
USE Import
COPY MEMO Temp TO MyFile.Txt
This worked perfecty but was much too slow for the large quantities I had to process. So I had to find another method.

I tried a few other methods to finaly find the fastest.
CREATE CURSOR OUTPUT (ASCI C(254)) && each ASCII line is approx. 150 caracters
SELECT * FROM INVOICE ;
   WHERE INVOICE.DATE BETWEEN m.BEG_DATE AND m.END_DATE ;
   ORDER BY INVOICE.INV_NUM INTO CURSOR TMP
SCAN
   * Prepare variable to contain the filtered/converted information
   * The Header information of the Invoice prepared 'by hand' in ASCII format
   INSERT INTO OUTPUT FROM MEMVAR

   SELECT INV_ITEMS
   NB_LINES=0
   SCAN FOR TMP.INV_NUM=INV_ITEMS.INV_NUM
      * Get, prepare and converts informations for each line of invoice
      INSERT INTO OUTPUT FROM MEMVAR
      NB_LINES=NB_LINES+1
   ENDSCAN
   * prepare ending line for this invoice
   ASCI='"E","'+ALLTRIM(STR(m.NB_LINES))+'"'
   INSERT INTO OUTPUT FROM MEMVAR
ENDSCAN
SELECT OUTPUT
COPY TO final.txt DELIMITED WITH BLANK
This method is very fast.

Thanks to all for your help and suggestions.
Réal Philippon
www.ultra.ca
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform