I would like to do the following:
- Open a file for reading
- Seek to a certain byte offset
- Overwrite the FIRST instance of "abc" to "def" (I will only be replacing equal-length strings)
- Save the file
I would like to do this efficiently as possible. The file is large (ReplaceAll has proven too slow), but the first instance of "abc" will be very close to the known byte offset.
I have tried to do this using SetStreamPosition[...], but I get the error "General::openw: OutputStream[...] is open for output".
Is it possible to seek to a byte offset and overwrite in Mathematica?