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

Exporting query wth memo field to type delimited file

Status
Not open for further replies.

ryebread

Programmer
Aug 13, 2001
29
US
I am exporting a query that returns a memo field using...

COPY TO "C:\pdf\memodata.csv" TYPE delimited

into a comma delimited file.

Life is good.. untill i realized that the memo field was not exported.

Any help?
 
You might try converting the memo field to a text field before exporting it. How many characters are in the largest memo field? I wrote a program that converts a memo field to one or more text fields of width 254 characters. If you want to use it, I'll be glad to email it to you. Just post your email address.

dz
 
my memo fields contain about 4 pages of text in each field. so the 254 char limit is a bummer.

I guess i can scan through the table and write each record to the text file by interating through each mline and adding it to the text file but use \n to represent the line breaks. was hoping there is an easier way.

I need to use these memo field text to import into a mysql db. So far the simplest way is to import with a delimited text file.


thanks for the help!

Ryan
 
Try:
repl all memofield with allt(memofield)
go top
copy MEMO memofield TO test.txt
for x = 2 to reccount()
go x
COPY MEMO memofield TO test.txt ADDITIVE
endfor
 
The amount of data that my program can handle is limited only by the number of fields it needs to create. It might not be useful in your application, but I used it to import a dbf into Access since the import function doesn't move memo fields. The program sets the memowidth to 254 characters, and creates a text field for each line in the memo field. I used 254 characters because that is the limit for a text field in FoxPro. If your memo field is 4000 characters (with no line breaks), the program would create 16 new text fields and copy the first line of the memo field to newfield1, the second line to newfield2, etc. Once you get the data into text fields and imported into the destination, you could concatenate the text fields into a single field on the new platform, obviously subject to the limitations of the new platform. If you think the program would help you, I'd be happy to give you a copy.

dz
 
Thanks for all the help! This is how I resolved my export problem.

----- export.prg -----------------------------------------


fpath="C:\webpages\memofoxpro\momed\"
fname="export.txt"

SET DEFAULT TO &fpath

foofighter= Fcreate(fname)

USE memodatatmp
SCAN

&& write id and date
expstr='"'+ALLTRIM(id)+'"*'+'"'+date+'"*'
=FWRITE(foofighter,expstr)


&&write subject
expstr='"'+STRTRAN(STRTRAN(ALLTRIM(subject),'*',''),'~','')+'"*"'
=FWRITE(foofighter,expstr)

&&write body
cntr=MEMLINES(body)
FOR i=1 TO cntr

bodym=MLINE(body,i)
expstr=STRTRAN(STRTRAN(ALLTRIM(bodym),'*',''),'~','')
=Fputs(foofighter,expstr)

endfor

&&write filename
expstr='"*"'+ALLTRIM(filename)+'"~'
Fwrite(foofighter,expstr)


ENDSCAN

FCLOSE(foofighter)
 
How can I export a dbf table, with a large memo field, to a csv or text file ?
Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top