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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Field Descriptions in Delimited Output

Status
Not open for further replies.

mwhitman52

Technical User
Apr 10, 2003
13
US
Does anyone have a way of including the field names in the first record of delimited output?
 
The Comma Separated Value field type for the COPY TO command wasn't introduced until VFP 6.0. (From the 6.0 Help file - A CSV file has the field names as the first line in the file, and the field values in the remainder of the file are separated with commas.)

You could always create one using code (e.g. Text merge), or use the available COPY TO options, and then go back and add in the first record - again much easier in VFP 6.0+, but possible in FP 2.x using low level IO - FOPEN(), etc.

Rick
 
You could copy to an Excel file (limit 16,384 records)
Syntax is COPY TO Filename TYPE XLS
From Excel you could create a CSV file
 
grab a table copy to a table called temp and place the code into a prg then runit


USE temp
COPY TO test.txt TYPE deli
fieldstring=''
FOR counter=1 to FCOUNT() step 1
fieldstring=fieldstring+ALLTRIM(FIELD(counter))+IIF(counter<FCOUNT(),',',CHR(10))
ENDFOR
filehand=FOPEN('test.txt',12)
=FWRITE(filehand,fieldstring,LEN(ALLTRIM(fieldstring)))
=FCLOSE(filehand)
CLOSE ALL
MODIFY COMMAND test.txt


Steve Bowman
steve.bowman@ultraex.com

 
FoxPro up through version 2.6a cannot copy to TYPE CSV. I'm not sure when Visual FoxPro got the functionality, but as stated above, VFP version 6.0 has it.

Here is an earlier thread: thread182-552995
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top