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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I copy a field to a text file and strip blank chars on

Status
Not open for further replies.

HAINC

IS-IT--Management
Mar 10, 2011
8
US
I have a file with approx 80,000 records. I need to copy one field "date1" to a text file and strip blank chars at the line.
I'm using Visual Foxpro 7. I tried to use trim with the copy to temp sdf command but it just gave me an error.
 
SDF format is defined by no delimiter nor separator, so fields are not trimmed, from that alone it doesn't make sense to trim the field while outputting. Besides that the COPY TO command only accepts a field list, not a list of expressions like ALLTRIM(field).

You can output to a txt file without COPY TO, There are FPUTS or STRTOFILE, just generate line by line, for example via STRTOFILE(Alltrim(date1)+chr(13)+chr(10),"out.txt",.t.) in a SCAN..ENDSCAN.

Bye, Olaf.
 
select date1 from myTable where not empty(date1) into cursor myCur

sele myCur
lcFile = putfiel('copy file')
if not empty(lcfile)
copy to (lcFile) delimited
endif

Ali Koumaiha
TeknoSoft Inc.
Michigan
 
Ok Ali, but that'll only remove completely blank records, I think HAINC wants to get rid of trailing space of each record, and that's not done with COPY TO.

Bye, Olaf.
 
Hmm, So, HAINC wants them like this?
01/01/20120101201301012014 etc..?
or
01/01/2012 (<- no space here, just chr(13)+chr(10))?
01/02/2012
HAINC, can you show us your desired output file.. how you want it to look like?


Ali Koumaiha
TeknoSoft Inc.
Michigan
 
Ali, Olf is correct I want to get rid of trailing space of each record. Below is a sample

Thank You

4954454D8006000500000001000000004716004009110000000047280040029000000000
47470040043F00000000475000400D93000000004759004003A1000000004765004000F9
000000004776004003E00000000047840040022A000000004796004006F6000000004799
00400207000000004811000000010000000048150000000D000000004889000000010000
000048990000001D0000000049000000000D000000004901000000030000000049590040
09C2000000008370006000040000000918070040020800000009310700401C3700000009
4011004000830000000940160040038500000009401700400033000000094020
4954454D8006000500000013000000094033000000010000000940510000002600000009
4053004006EE000000094060004005E6000000094074000000030000000940790040025B
000000094103004000700000000941300040084300000009413100400603000000094135
004000D20000000944090040046A00000009441600400060000000094550004001440000
000948160000000C00000009495900000002000045019300000000010000450193020060
001600050000040100600002000500000402006000330005000004040060002200050000
0405000000010008346026520000000100083460705700000001000834613738
 
Well, then a soluion is STRTOFILE(Alltrim(date1)+chr(13)+chr(10),"out.txt",.t.) in a SCAN..ENDSCAN

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top