Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy TO fixed length,comma separated VFP 7

Status
Not open for further replies.

fitedgar

MIS
Apr 24, 2002
238
US
I have a table which needs to export to file. This file
is read by a mainframe.
The file needs to be fixed length, comma separated.
EX.
Table: manifest(6),qty n(3,0),carton c(10),D
The file needs to be as follows (assuming 2 records december 1 2002 YYYYMMDD)
01234 , 1,1234567890,20021201,
M12345, 10,1234567890,20021201

I have tried COPY to xxx.txt type CSV but it does not
contain commas and the date format.
Can I parse this to file?
Thank you
EMC
 
It's easiest to just use low level routines:
Code:
STORE 'MyTxtFile.TXT' TO fOutFile
IF FOPEN(fOutFile) < 0
   *... error
ENDIF

USE MyTable
SCAN
   FPUTS(fOutFile,;
         manifest + ',' + ;
         STR(qty) + ',' + ; 
         carton + ',' +   ;
         DTOS(D))
ENDSCAN
FCLOSE(fOutFile)
You may have to tweak the data conversions and formatting a little, but you get the idea.
Dave S.
 
Hi

COPY TO test.txt TYPE DELIMITED WITH ','

:) ramani :)
(Subramanian.G),FoxAcc, ramani_g@yahoo.com
 
What do you mean, &quot;I have tried COPY to xxx.txt type CSV but it does not contain commas...&quot;

In all my trials, &quot;TYPE CSV&quot; DOES contain commas... &quot;TYPE SDF&quot; does not; CSV will also put quotes (&quot;) around all strings, which apparently you don't want. TYPE DELIMITED WITH ',' as ramani suggests will not put the quotes there... but wont format the dates right either.

To get the date format correct, you probably will have to create a temporary cursor with the date converted to either a number or a string in the proper format.

DTOS() does the conversion to the right date format quickly.
(YYYYMMDD)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top