![]() |
Replace Bytes in File between Value X and Y with Z - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: Data Science (https://python-forum.io/forum-44.html) +--- Thread: Replace Bytes in File between Value X and Y with Z (/thread-24214.html) |
Replace Bytes in File between Value X and Y with Z - lastyle - Feb-04-2020 Hi all I`ve got a File that contains different Byte Values and i need some of them to be exchanged. Idea is to read the entire File into an Array and then using a routine like : If byte Value is between 193 and 219 then substract 129 from it and replace with the new Value in the array. Open File and after exchange that is plain Simple, but how would a Function like this look like ? Thanks for any Help guiding me there ![]() RE: Replace Bytes in File between Value X and Y with Z - Larz60+ - Feb-04-2020 What have you tried so far? RE: Replace Bytes in File between Value X and Y with Z - lastyle - Feb-04-2020 (Feb-04-2020, 06:35 PM)Larz60+ Wrote: What have you tried so far? to be honest, nothing. I dont know which function i should use for a compare between value x and y In vb.net i am more experienced and would parse like Public Sub parsefile(filename As String) Dim bytes As Byte() = System.IO.File.ReadAllBytes(filename) For i = 0 To bytes.length if val(bytes(i)) > 193 < 219 then val(bytes(i)) = val(bytes(i))-129 Next i End Sub But here with python i have no idea, thats why i am hoping somebody would help me RE: Replace Bytes in File between Value X and Y with Z - Larz60+ - Feb-04-2020 looks like you need to start with a python tutorial, I'll list a couple of good ones below. I will show examples for:
These are both excellent tutorials: How to Think Like a Computer Scientist: Interactive Edition Python3 Tutorial |