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

COPY TO CSV WITHOUT FIELD NAMES

Status
Not open for further replies.

scrimej

Programmer
Dec 22, 2004
17
0
0
US
Using FoxPro 9.0
Trying to create a CSV file using the COPY TO command and would like to know if there is an automated way of removing the field names from the first record?

Thanks,
Jeremy
 
Code:
COPY TO c:\test.csv TYPE CSV
lcString = FILETOSTR([c:\test.csv])
lcString = SUBSTR(lcString,AT(CHR(13),lcString)+2)
STRTOFILE(lcString,"c:\test.csv")

Other way

Code:
COPY TO c:\test.csv DELIMITED WITH ","
But that way delimiter is always comma. Excel can't open this file as CSV if in Regional settings of the computer list separator is different char


Borislav Borissov
 
Borislav,

are you sure there is a regional difference in delimiters of CVS files? I think there are only regional differences in decimal point, seperator of large numbers (every three digits) and the mark that separates the parts day, month and year of a date.

Even if there is also a regional CVS separator there should be some API call to be able to get that information from the OS and use it as delimiter character with the COPY TO command you provided.

I just exported a worksheet from within Excel to either OS/2 or MSDOS CVS and Mac CVS format and Excel separated with a semicolon. So you may be right, but nevertheess Excel can also import these files if I modify the semicolons to commas. Also the icon of a link to a CVS file shows "a," on a sheet, which is a hint, that a comma is always accepted as seperator. The CVS format wouldn't really make sense, if there were so many different implementations of it. It surely is difficult enough, that there can be a first line containing field names or not and lines can be separated by CHR(13) alone or CHR(13)+CHR(10).

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top