0

Working on reading and interpreting FAT12 directory entries. I am trying to determine how to read 32 bytes of the file at a time. So far I have the following:

f_name = sys.argv[1] #set file name as the argument to be passed in command line

with open(f_name, mode='rb') as file:
    data = file.read()

struct.unpack(,data[:])

Most of the things I have seen say to use struct.unpack() I have looked at the documentation on this and I am having trouble understanding how to use it. Is there an easier way to read 32 bytes at a time until I have read a full 512 bytes?

Zack Herbert
  • 942
  • 1
  • 16
  • 39

1 Answers1

1

file.read() takes the upper limit of bytes/characters to read and advance the read pointer by:

data = file.read(32)
Ignacio Vazquez-Abrams
  • 776,304
  • 153
  • 1,341
  • 1,358