Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
COPY TO DELIMITED - field headers?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01016259
Message ID:
01016295
Vues:
7
>>If you COPY TO file XLS, you get field headers. If you do COPY TO textfile DELIMITED WITH TAB,
>>though, you just get the data. Is there any way to get around this short of manually writing
>>out the fields as the first record? Thanks.
>You may issue:
>go bott
>copy to ... csv next 1 && get the header

That's reasonably efficient. Thanks!
lcTable = GETFILE("DBF", "Table:", "Open", 0, "Select file to export")
lcExport = PUTFILE("Export to:", FORCEEXT(lcTable, "TXT"), "TXT")

lcTempFile = SYS(3)


USE (lcTable)
COPY TO (lcTempFile) CSV NEXT 0
lcHeaders = FILETOSTR(FORCEEXT(lcTempFile, "CSV"))
lcHeaders = STRTRAN(lcHeaders, [,], ["]+CHR(9)+["])
lcHeaders = ["] + LEFT(lcHeaders, LEN(lcHeaders) - 2) + ["]

COPY TO (lcTempFile) DELIMITED WITH TAB 

lcOutFile = lcHeaders + CHR(13) + CHR(10) + FILETOSTR(lcTempFile + ".txt")
STRTOFILE(lcOutFile, lcExport)

ERASE &lcTempFile..csv
ERASE &lcTempFile..txt
My blog
My consulting page
My home page

Member of the Trim Your Auto-Quote Campaign!
What's another word for thesaurus?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform