I'm trying to convert some code using the readBin function (R) into Python.
R code:
datFile = file("https://stats.idre.ucla.edu/stat/r/faq/bintest.dat", "rb")
i<-readBin(datFile, integer(), n = 4, size=8, endian = "little", signed=FALSE)
print(i)
Returns:
[1] 1 3 5 7
My attempt in Python:
with open("bintest.dat", "rb") as datfile:
i = int.from_bytes(datfile.read(8), byteorder='little', signed=False)
print(i)
Returns:
8589934593
How can I get the same output in Python (I know that I'm missing the n parameter, but I can't find a way to implement it properly).
Thanks