python: add read bytes from vec example

This commit is contained in:
nym21
2025-02-12 17:22:36 +01:00
parent 27b270148b
commit b034b4fe2f
9 changed files with 1221 additions and 2 deletions

12
python/example.py Normal file
View File

@@ -0,0 +1,12 @@
# Here's an example on how to parse the output from the indexer
# We're aiming to read the first 21 values from the height_to_timestamp vec
import sys
import datetime
with open("../_outputs/indexes/vecs/height_to_timestamp/vec", "rb") as file:
for x in range(0, 21):
bytes = file.read(4) # Need to check the rust side to find the size, at least for now
number = int.from_bytes(bytes, sys.byteorder)
date = datetime.date.fromtimestamp(number)
print(date)