Wiki Home

Copy To Delimited


Namespace: VFP
COPY TO Filename [ [ TYPE ] DELIMITED [ WITH Delimiter | WITH BLANK | WITH TAB ][ WITH CHARACTER Separator ]
"On the whole, the choices are quite a mess. If you're still confused by this, we suggest you do what we did to figure all this out. Try COPY TO with each option on a small data sample." -- Hackers Guide


I did so you don't have to. Let me know if I missed any. -- Carl Karsten

Notes:
  • delimited WITH CHARACTER ' (single quote) causes it to be delimited with CR's.
  • you don't get the memo field. you can change memos into char like this: select cFid, padr( mFid, 30) as cFid2, nFid, lFid, dFid from test into cursor qtest but becareful about the width of the resulting cFid2 field or you may chop off the end of the memo.
    * CopyTo2.prg
    * Generated 07/10/2003 11:33:31 AM
    
    copy to test1.txt type delimited
    "sam",123.45,T,03/24/1966
    
    copy to test2.txt type delimited WITH CHARACTER $
    "sam"$123.45$T$03/24/1966
    
    copy to test3.txt type delimited WITH CHARACTER ,
    "sam",123.45,T,03/24/1966
    
    copy to test4.txt type delimited WITH CHARACTER '
    "sam"
    123.45
    T
    03/24/1966
    
    copy to test5.txt type delimited WITH !
    !sam!,123.45,T,03/24/1966
    
    copy to test6.txt type delimited WITH ! WITH CHARACTER ,
    !sam!,123.45,T,03/24/1966
    
    copy to test7.txt type delimited WITH ! WITH CHARACTER $
    !sam!$123.45$T$03/24/1966
    
    copy to test8.txt type delimited WITH ! WITH CHARACTER "
    !sam!"123.45"T"03/24/1966
    
    copy to test9.txt type delimited WITH ! WITH CHARACTER '
    !sam!
    123.45
    T
    03/24/1966
    
    copy to test10.txt type delimited WITH "" WITH CHARACTER "|"
    sam|123.45|T|03/24/1966
    
    copy to test11.txt type delimited WITH BLANK
    "sam" 123.45 T 03/24/1966
    
    
    copy to test12.txt type delimited WITH "" WITH CHARACTER TAB
    sam	123.45	T	03/24/1966
    
    copy to test13.txt type delimited WITH BLANK WITH CHARACTER X
    Error: Syntax error.
    

    (program to generate the above example: _ Copy To Prg)
    One thing I've found is that if you have COPY TO SomeTxtFile DELIM WITH " that the Beautifier chokes on the double quotes -- Doug Dodge

    copy to test14.txt type delimited WITH TAB
    "sam"	123.45	T	03/24/1966
    

    Contributors Carl Karsten


    Category VFP Commands Category Code Samples Category Text Files
  • ( Topic last updated: 2011.09.13 08:29:29 AM )