Information générale
Catégorie:
Codage, syntaxe et commandes
Titre:
Tab Separated Values
FYI, here's a quick routine that I put together to write out tab separated values (tsv) with field labels in the first row and unquoted fields. This is a common format in my environment for passing data between systems. I could not find a way to write out to this format using COPY TO:
* TSV.PRG
FUNCTION tsv
* Purpose.........: Read in FoxPro table and writeout tab-separated values that are labelled and unquoted
* Origination.....: Greg Griffith on 08/16/2000
* Calling example.: =tsv('empps.dbf','empps.txt')
LPARAMETER tcFileIn, tcFileOut
USE (tcFileIn) ALIAS FileIn IN 0
GOTO TOP
nFieldCount=AFIELDS(laFields,'FileIn')
SET TEXTMERGE TO (tcFileOut)
SET TEXTMERGE ON NOSHOW
FOR ni = 1 TO nFieldCount-1
\\<> <>
ENDFOR
\\<>
SELECT FileIn
SCAN
*-- I like chatter...
WAIT WINDOW NOWAIT "Processing record number " + STR(RECNO("filein")) + "..."
ni=1
\<>
FOR ni=2 TO nFieldCount
IF TYPE("EVALUATE(LAFIELDS(NI,1))") = "D"
IF EMPTY(EVALUATE(LAFIELDS(NI,1)))
\\<>
ELSE
\\<><>
ENDIF
ELSE
\\<><>
ENDIF
ENDFOR
ENDSCAN
WAIT CLEAR
SET TEXTMERGE OFF
SET TEXTMERGE TO
USE IN FILEIN
*: eof
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement