General information
Category:
Coding, syntax & commands
Title:
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
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only