editing text files from Access

G

Guest

I have these text files that have somewhere in them "<< start-here001 >> I
have a Access 2003 table with two fields. Field 1 contains "start-here001,
start-here002 and so on. Field 2 has the text I want to replace with "gone
tomorrow001" for example.

I've been able to open and write to a text file but I can't seem to do a
find and replace.

Any suggestions?
 
J

John Nurick

Hi Jaime,

Beneath the surface, text file editing always involves reading the
existing file and writing a new one with the desired changes. (This is
because there's no other way of inserting new data between bytes in a
file, or deleting bytes from the middle of a file.)

If the files are reasonably short - up to a few megabytes, perhaps - you
can read the entire contents into a string variable, modify the string
as required, and then write it back to a new file with the same name. If
desired, rename the original file first (e.g. to *.BAK). Search
http://groups.google.com for
FileContentsAsString WriteToFile
and my name and you'll find a couple of functions for the reading and
writing.

If the files are too large to read comfortably in one piece, you need to
deal with them a bit at a time. This is easy if you can do it
line-by-line, but can get complicated if you need to search for things
that can span more than one line.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top