Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Tab Separated Values
Message
From
17/08/2000 16:40:10
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Tab Separated Values
Miscellaneous
Thread ID:
00406399
Message ID:
00406399
Views:
66
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
Map
View

Click here to load this message in the networking platform