Export Data to a File Weirdness

GCC Consulting gcc at optonline.net
Wed Apr 6 13:32:09 PDT 2005


 

> -----Original Message-----
> From: filepro-list-bounces at lists.celestial.com 
> [mailto:filepro-list-bounces at lists.celestial.com] On Behalf 
> Of DataDoIt
> Sent: Wednesday, April 06, 2005 2:33 PM
> To: 'filePro mailing list'
> Subject: Export Data to a File Weirdness
> 
> fPODBC v1 on Win2k3 Server;
> 
> I have created a simple export routine that compiles data 
> into a variable,
> then:
> 
> SYSTEM "ECHO " & variable & " >> file.csv"
> 
> All is well when developing this and testing, but doesn't 
> work in production.  The difference?  Development is on the 
> same machine under c:\development\filepro, and production is 
> the normal c:\filepro.  The fP stuff is under c:\fp for which 
> both development and production share.
> 
> In the development version of the data, the export works 
> perfectly.  The order of events are:
> 
> 1. Deletes the file that's already there using:
>    SYSTEM "DEL file.csv"
> 
> 2. Exports out a header routine that sends out the column 
> headers using:
>    SYSTEM "ECHO " & header & " >> file.csv"
> 
> 3. Finally exports out the data using the above.
> 
> On production, it'll remove the file okay.  It'll write the 
> header info okay, but won't write the data.  I've verified 
> that there's data in the variable.  What in the world could 
> this be?  The only difference is filePro data folder on the 
> same machine.
> 
> Thanks.
> 
> -MikeR

Just a quick question, why bother to system out to create this file?  You can
create the header & details from within processing.  Many of us do this every
day without a problem.

Below is code I use for one csv file.  The application resides on network drive
O and is created on the local computer on drive C, folder temp.  By creating a
separate local temp folder, I can delete anything in it as only filepro writes
to it.  This also avoids the problem of having others step on the process.

When the first record is processed, the header is written and the program loops
back to export the data from the first record.  The one caveat to this method is
that you can only have 1 subtotal level.  If for some reason you export has
multiple sub totals, set a global variable so the header is only exported at the
first record.

Lines 19-25 can be combined.  I prefer to separate them for clarity.  See line
16 where the data is exported.

 2  Then: '* File: company
         If: '* Program: salon_csv - create an export file for use in Excel*
    3  Then: '*             *
         If: '* Created:09/26/03             *
    4  Then: '* Modified:             *
         If: '* Version:             *
    5  Then: '* Mod Desc:             *
        If: '*             *
       9  Then: export WORD com=c:\temp\salon.csv
         If: @rs = "1"               'export row 1 header info
   10  Then: GOSUB exp_hed
         If: mid(2,"1","3") ne "CVS"
   11  Then: END
         If: 'store #
   12  Then: aa(len(20),edit(20))=20
         If: 'address
   13  Then: ab(len(3),edit(3))=address1
         If: 'city                 state                  zip code
   14  Then: ac(len(4),edit(4))=4;ad(len(5),edit(5))=5;ae(10,*)=6
         If: 'phone
   15  Then: af(len(7),edit(7))=7
         If: 'post destils
   16  Then: com(1)=aa;com(2)=ab;com(3)=ac;com(4)=ad;com(5)=ae;com(6)=af
   17  Then: END
exp_hed  If: '**************************************************************
   18  Then: '* export the first row (header info for Excel spreadsheet)
   19  Then: com(1)="Store"
   20  Then: com(2)="Address"
   21  Then: com(3)="City"
   22  Then: com(4)="State"
   23  Then: com(5)="Zip"
   24  Then: com(6)="Phone #"
   25  Then: write;RETURN
@once    If: '***********************************************
   26  Then: '*
   27  Then: msgbox "Program will export to\n\r c:\\temp\\salon.csv \r\n --- "
   28  Then: END

Richard Kreiss
GCC Consulting 




More information about the Filepro-list mailing list