Pregunta

I have a large text file that I would like a split into an arbitrary number of smaller ones. The behavior I need is nearly identical to the split terminal command except that I need the files to overlap on their last lines. That is, the last line of the first file is the first line of the second file, the last line of the second file is the first line of the third file, et cetera.

The naive solution seems to read lines in from the original text file and split when necessary. I'm wondering if there is a standard library function that will allow me to deal with bytes rather than strings to more easily split the text file uniformly.

Is there something analogous to fseek in Go that will let me do this?

¿Fue útil?

Solución

For example,

Package os

func (*File) Seek

func (f *File) Seek(offset int64, whence int) (ret int64, err error)

Seek sets the offset for the next Read or Write on file to offset, interpreted according to whence: 0 means relative to the origin of the file, 1 means relative to the current offset, and 2 means relative to the end. It returns the new offset and an error, if any.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top