Sep-19-2020, 07:33 PM
(This post was last modified: Sep-19-2020, 07:33 PM by MysticLord.)
I have a table of bytes (actually they're bit flags, but one concept at a time), as below.
My code:
I'm not sure if you can seek in lines in a text file either, and how writing behaves in such a case.
edit
Or maybe it requires stores, since it's sort of a sorting algorithm?
FB 2C D2 93 40 00 00 00 00 00 00 00 EA C8 61 00 F9 AA F0 D7 C0 00 00 00 00 00 00 00 FD 28 CA 00 E2 49 B4 8B 50 00 00 00 00 00 00 00 F2 4B CE 00 E8 99 A4 4B B0 00 00 00 00 00 00 00 E1 37 D7 00 82 0E 00 C3 40 00 00 00 00 00 00 00 DE 89 19 00 F5 F1 FB 1F F0 00 00 00 00 00 00 00 E3 FE E6 00 FA E7 D2 DF D0 00 00 00 00 00 00 00 F5 EC F5 00 FF F9 FF 1F F0 00 00 00 00 00 00 00 F4 BD 79 00 FB C6 92 D3 20 00 00 00 00 00 00 00 FF FA FE 00 FB C9 54 03 D0 00 00 00 00 00 00 00 FF 13 0A 00 C9 96 92 CB B0 00 00 00 00 00 00 00 C5 1E BD 00 FB EE D2 C3 77 00 00 00 00 00 07 FC EA E9 F9 00 FD F9 FD 57 E0 00 00 00 00 00 00 00 F7 7D 7D 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00I want to print it with the columns and rows switched, as done partially below.
FB F9 ... 2C AA ... D2 F0 ... 93 D7 ... 40 C0 ... 00 00 ... 00 00 ... 00 00 ... 00 00 ... 00 00 ... 00 00 ... 00 00 ... EA FD ... C8 28 ... 61 CA ... 00 00 ...I'm having a hard time mentally grasping how to track and iterate the seeks to do this.
My code:
import io,sys with open(sys.argv[1], 'rb') as scus: baseAddr =58364 #scus.seek(baseAddr) #print(scus.read(1)[0], end='\' ') with open("sparks.txt", 'w') as writer: listCtr = 0 entryCtr = 0 while listCtr < 16: scus.seek(baseAddr + listCtr + entryCtr) print(hex(scus.read(1)[0])[2:].zfill(2) + "-") listCtr += 1 print()My output:
python extractSparkTalents.py SCUS_942.30 fb- 2c- d2- 93- 40- 00- 00- 00- 00- 00- 00- 00- ea- c8- 61- 00-It seems like it requires recursion, or maybe a specialized type of string splitting where you put line breaks between the strings.
I'm not sure if you can seek in lines in a text file either, and how writing behaves in such a case.
edit
Or maybe it requires stores, since it's sort of a sorting algorithm?