I would like to read binary data into floating point numbers. I'd be happy with a 1-D array (or vector) or a 2-D array. Just something I can write to a text file. I attached a small sample of this data. Here is the code I have so far based on googling this topic. I'm using python 2.5.
filex='test.bin' gq= f = open(inputname, "rb") try: byte = f.read(1) while byte != "": # Do stuff with byte. byte = f.read(1) print byte ## num=2bytes I need a line here that converts bytes to numbers #gq.append(num) #outfile=open('output.txt','w') #outfile.write(gq)
I am able to read and print the bytes, but how do I convert them to data to append them for writing? The bytes appear very interesting.
I know the data is in raw binary format (with little-endian—Intel PC—byte order), and that two bytes is one value, and that the number of rows 240, and the number of columns 480 (for this test data set).
Any ideas are invited.
Also, Does anyone know how I can change the name of my Daniweb Avatar?