Writing CSV file and converting it to NPY

I am a newbie, also in python, so please comment

I am using the key 0xFEDCBA9876543210

In hex a CSV file could possibly look like:
However, I believe I have to use decimal:
Is printing least significant byte first correct?

To read the CSV file into numpy I do:
import numpy as np
knownkey=np.genfromtxt(“knownkey.csv”, dtype=‘uint8’, delimiter=",")
I can use the table now or save it in an NPY file:
np.save(“knownkey.npy”, knownkey)

I assume setting dtype to ‘uint8’ makes sure I get a compact table in memory.
print(knownkey) outputs:
array([ 16, 50, 84, 118, 152, 186, 220, 254], dtype=uint8)

All good so far?

Or should I just print my 64 bit key as 18364758544493064720 into my CSV file?


Yup, that all looks correct - the endianness looks right, np.genfromtxt seems to have no way to deal with hex numbers, and dtype=uint8 ensures your data will be an 8-bit integer.

I’d personally store each byte separately, but so long as you get the numbers right, but you may find it more convenient to store as a 64-bit integer.