How to search a text file for double quotes and replace with single quotes

bpichette

New Member
Licensed User
I have a text file in csv format, fields separated by commas and text fields wrapped with double quotes. I need to replace the double quotes with single quotes and while I did something similar years ago with dbase and foxpro, I can't seem to figure out how to do it with basic4ppc. Any help would be appreciated.

Thanks in advance!
Barry
 

timsteeman

Member
Licensed User
Longtime User
Like this?

FileOpen(c1,"text.txt",cRead)
r=FileReadToEnd(c1)
r=StrReplace(r,Chr(34),Chr(39))
Msgbox(r)
FileClose(c1)
FileOpen(c1,"text.txt",cWrite)
FileWrite(c1,r)
FileClose(c1)
 

bpichette

New Member
Licensed User
Thanks

Thanks timsteeman - I appreciate the hint of using chr(34) and chr(39) and wanted to acknowledge that. I found that I had to do it record by record since FileReadToEnd threw an out of memory condition. The file I'm working with is over 100MB but I do have it working now.
 
Top