0

I am trying to construct a memory map file for a large binary file where I give it a dictionary of dtypes, offsets, and shapes and want it to repeat for a specified amount. Is there a way to do this like you can in the Matlab memmapfile.m? Thanks!

so far I have the following but I only get the first record and I need to repeat it 798 more times throughout the file.

numpy.memmap(fileName,dtype=float,mode='r',offset=511,shape=(2,1))    

I get the first array of data for that datatype but I need to repeat it 798 more times within the file.

Ahmed AEK
  • 8,584
  • 2
  • 7
  • 23
Michelle
  • 11
  • 3
  • Are you trying to get a 798x2x1 array as a result? Shouldn't you make the shape `(798,2,1)`? – Tim Roberts Nov 08 '22 at 18:04
  • i think you are asking about the `repeat` parameter in matlab and whether we have a similar one in python ... you can use Tim Roberts suggestion and just add the repeat number in the first dimension. – Ahmed AEK Nov 08 '22 at 18:23
  • Hi Ahmed, what exactly is the repeat parameter doing in matlab? Is it just repeating the structure I give it 798 times? , yes the end result will be a 798x2x1 – Michelle Nov 09 '22 at 19:10
  • Thanks Tim, yes the end result will be a 798x2x1, but really I have a dictionary of formats, offsets, and shapes that I want repeated 798 times in the file. If I did that would it get all the correct data in the order I need?ideally my dtype would be {Names: ("x1","x2","x3","x4","x5","x6"),formats: (double, int, 'single', int, int, int), offsets: (512, 520, 528, 556,4556, 8556), shapes: ((1,1),(2,1),(7,1),(1,1000), (1,1000), (1,1000)} I can do this once and I get the right results but I don't know how to go through the rest of the file and get the other 797. – Michelle Nov 09 '22 at 19:20
  • Hi, I added the repeat number in the first dimension but that didn't work. – Michelle Nov 14 '22 at 17:42

0 Answers0