I would like to read from a binary as float values and write them to a csv file, which almost works with the code below. The thing is struct.unpack is writing the float value like:
(number,)
and I would like to write it without the paranteses,().
Is there a better way to get the values as a float instead of using unpack or what do you suggest?
count = 0
output_file = open(r"C:\Users\heltbork\Desktop\binTocsvDirect\00000006.txt", "w")
with open(r"C:\Users\heltbork\Desktop\binTocsvDirect\00000006.bin", "rb") as f:
while True:
byte = f.read(4)
if not byte:
break
output_file.write(str(unpack('f', byte)))
count = count + 1
if count == 6:
count = 0
output_file.write("\n")