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

How to "COPY TO <filename>. DELIMITED WITH ';'" from comma

Status
Not open for further replies.

HMS21

IS-IT--Management
Feb 10, 2002
1
US
I'm new to Foxpro, any help is greatly appreciated.

I want to dump a table to a CSV file. I know I can open the table and execute a copy command like
COPY TO <filename>. DELIMITED WITH ';'

but I need to do this via a batch program, so I need to execute the copy from the command prompt.
 
I don't believe there is any way to dump a table to a .csv file except from within FoxPro. To do it from a command prompt you could create a small prog and compile it into a .exe to be run from a batch file. The documentation says 'COPY TO myfile.csv type CSV DELIMITED WITH &quot;,&quot;', but I have used simply &quot;copy to myfile.csv deli&quot; successfully for several years now. Both examples assume the table is open.

I didn't understand the &quot;;&quot; in your questions. Do want to use a semi-colon for the delimiter?
 
If you want to do this from the (presumably DOS) command prompt, you need to create an .EXE to do this. The minimal way to do this, would be to create a project with a single .PRG file that would look something like this:
Code:
* MAIN.PRG
LPARAMETERS p_cTableName, p_cOutput
USE (p_cTableName)
COPY TO (p_cOutput) DELIMITED WITH ';'
RETURN

Of course, you should probably add some error checking to make sure the Table exists and optionally allow overwriting the output file if it already exists.
Note: If you run this on a system were VFP isn't installed, then you'll need to make sure the runtime files are installed. But if it has .DBFs, you probably already have another VFP application installed.

Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top