如何从Julia的开头开始读取文件x字节? [英] How to start reading a file x bytes from the beginning in Julia?

查看:49
本文介绍了如何从Julia的开头开始读取文件x字节?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从文件中读取记录,每个记录长9个字节.我需要知道如何从文件的不同位置开始读取

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

推荐答案

您似乎正在寻找seek函数:

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

  seek(s, pos)

  Seek a stream to the given position.

尤其是您可能想要

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

还有skip功能可能会有用

help?> skip
search: skip skipchars

  skip(s, offset)

  Seek a stream relative to the current position.

这篇关于如何从Julia的开头开始读取文件x字节?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆