Hi:
how to overwrite the old data in *.txt with only little steps, I did somehow in a very complicated way.
thanx
Hi:
how to overwrite the old data in *.txt with only little steps, I did somehow in a very complicated way.
thanx
Don't laugh at me,I am just a SuperNewbie.
I guess the easiest way for small files would be read it all into one string, replace what you need, and write it all back.
hth
-nv
She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."
When in doubt, read the FAQ.
Then ask a smart question.
NVoigt,
What is the best approach for big files? Should I still read, edit and write? How could I seach for a string, position there, and overwrite that string? Any ideas?????
Thanks,
Kendal
Replacing a string in a file is always messy, because you can only do this if the strings lengths' match. Therefore, I would suggest reading the input file line by line, replacing in each line and writing it back to a seperate output file. Once this is done, the input can be deleted and the output renamed to the former input.
If your replacement can span more than one line, the reading/writing part becomes a bit tricky, but basically, the input, copy, delete, rename output would stay the same.
hth
-nv
She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."
When in doubt, read the FAQ.
Then ask a smart question.
Gotcha,
I appreciate it.
Thanks again,
Kendal