Python Forum
Save multiple Parts of Bytearray to File ?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Save multiple Parts of Bytearray to File ?
#1
Hi all.

i`ve got an fixed Bytearray which consist of a $40 Bytes FileHeader and $10 Bytes Packet Header followed by $2000 Bytes Raw data

From that Array i need to Extract the first Package ($2000 Bytes) Starting at $0050, save it and then extracht the next Pack at $2060, save, next Package at $4070 and so on until i reach the End of the Array.

I thought best way is to Copy the wanted data to a new array and save it from there and when finished grab new Data. Sadly i fail to code a working Function that Grabs the Data from the Source Array. Anybody here who can give me a hint how to start ?

Thanks for reading
Reply
#2
You can loop with range
for k in range(50, len(array), 2010):
    chunk = array[k:k+2000]
    # do something with chunk
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Open/save file on Android frohr 0 336 Jan-24-2024, 06:28 PM
Last Post: frohr
  how to save to multiple locations during save cubangt 1 559 Oct-23-2023, 10:16 PM
Last Post: deanhystad
  save values permanently in python (perhaps not in a text file)? flash77 8 1,246 Jul-07-2023, 05:44 PM
Last Post: flash77
  Value error when converting hex value to bytearray shubhamjainj 7 10,562 Mar-20-2023, 05:30 PM
Last Post: Skaperen
  appending to a bytearray Skaperen 21 14,456 Mar-19-2023, 11:05 PM
Last Post: Skaperen
  Split Bytearray into separate Files by Hex delimter lastyle 5 2,676 Mar-09-2023, 07:49 AM
Last Post: bowlofred
  Save and Close Excel File avd88 0 3,081 Feb-20-2023, 07:19 PM
Last Post: avd88
  bytearray object - why converting to ascii? Chepilo 2 1,643 Nov-21-2022, 07:25 PM
Last Post: Chepilo
  Matching multiple parts in string fozz 31 6,346 Jun-13-2022, 09:38 AM
Last Post: fozz
  Extract parts of multiple log-files and put it in a dataframe hasiro 4 2,096 Apr-27-2022, 12:44 PM
Last Post: hasiro

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020