Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start reading a file x bytes from the beginning in Julia?

Tags:

julia

I need to read records from a file, each being 9 bytes long. I need to know how to start reading at different points in the file

like image 841
Jonathan Livingston Avatar asked Oct 12 '25 09:10

Jonathan Livingston


1 Answers

It looks like you're looking for the seek function:

help?> seek
search: seek seekend seekstart ParseError setenv select select! selectperm

  seek(s, pos)

  Seek a stream to the given position.

In particular you might want to

open(filename) do f
    seek(f, n)  # seek past nth byte
    read(f, m)  # read m bytes
end

There is also the skip function that may come in useful

help?> skip
search: skip skipchars

  skip(s, offset)

  Seek a stream relative to the current position.
like image 141
Fengyang Wang Avatar answered Oct 13 '25 21:10

Fengyang Wang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!