Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sending dbf to txt file 1

Status
Not open for further replies.

1421

Technical User
Feb 24, 2004
69
Hi All,

I am copying a dbf file to txt file (copy...delimited with ' ') and the resulting txt file has a space at the end of each line, as i am delimeting by space. Is there a way not to send that extra space and the rest of the data on the line (80 characters each line) should be nothing (null?)?

Thank You
 
Is this what you ar trying to do ???
Code:
LOCAL lcString
USE YourDBF
lnHandle=fcreate(YourFile.txt)
if lnHandle > 0
   SCAN ...........
        lcString = Transform(Field#1) + " "
        lcString = lcString + Transform(Field#2)+ " "
        ...... Etc
        FPUT(lnHandle,lcString)
   ENDSCAN
   FCLOSE(lnHandle)
ENDIF


David W. Grewe Dave
 
Code:
copy to ... type sdf

You will have no delimiter at all but fields are written with fixed width.

The delimited with delimier clause of the copy command determines how strings/char fields are delimited, not how fields in general are separated, therefore you get the space at the end of the line. You might want

Code:
copy to ... delimited with space(0) with character ','

to get comma separated fields and no delimiter of char fields.

Bye, Olaf.
 
Thanks all, for your reply. the 'sdf' option did not resolve the problem, as i was still getting spaces at the end of the data line. But the low-level file functions did the job. Thank you!
 
okay, space(0) in the second statement does error, '' instead runs but defaults to quotation marks around char fields.

You could do
Code:
copy to ... type delimited with '@' with character ' '

and afterwards remove @ chars from the resulting file. If @ is within the text use some other unused character.

Bye, Olaf.
 
Olaf's solution should work. The problem will arrive if the last field is not type numeric(N). See the fix below.

Code:
* Field names are in UPPERCASE
* Version VFP 9.0
replace all LASTFIELD with trim(LASTFIELD)+replicate(chr(0),len(LASTFIELD))
copy to t.txt sdf


Nasib Kalsi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top