Does anyone have an example of using Using mmap.mmap
and re.finditer with a marker to split binary files?
Forgot to add ... on binary data
and re.finditer with a marker to split binary files?
Forgot to add ... on binary data
Using mmap.mmap and re.finditer
|
Does anyone have an example of using Using mmap.mmap
and re.finditer with a marker to split binary files? Forgot to add ... on binary data
Found the following code on stackoverflow:
here import mmap import re with open('somefile', 'rb') as fin: mf = mmap.mmap(fin.fileno(), 0, access=mmap.ACCESS_READ) markers = re.finditer('(.*?)MARKER', mf) for marker in markers: print (marker.group(1))This looks like exactly what I'm looking for ... Now to test I'll report back on how it works
Apr-26-2017, 12:03 PM
The only thing I remember about mmap is that it allows me to make a storage in memory and use it like a real one. If I am not wrong. I'm not on the Earth right now. Don't feel well
Apr-26-2017, 02:57 PM
That is correct.
I know how that works, what I was trying to do was place markers in the memory map with re.finditer so that I could extract any of the 170,000 items that are in it. I've since succeeded, so am OK |
|
Possibly Related Threads… | |||||
Thread | Author | Replies | Views | Last Post | |
Random access binary files with mmap - drastically slows with big files | danart | 1 | 5,137 |
Jun-17-2019, 10:45 AM Last Post: danart |
|
re.finditer issue, output is blank | anna | 1 | 3,090 |
Feb-07-2019, 10:41 AM Last Post: stranac |
|
Dealing with strings thru mmap in Python | doublezero | 4 | 9,709 |
Mar-01-2017, 06:33 PM Last Post: zivoni |