[Tutor] Windows problem with large(?) files

johan nilsson johanpo at googlemail.com
Thu Feb 2 09:54:59 CET 2006


Dear group,

I have a few files that contains data in IEEE 754 format. I need to
transform them into a csv file, to be able to read these files in another
program. Each file has 30000 samples of I and Q. I did develop the attached
script. I am sure not the best, but it worked at home on my Linux
installation Python 2.4. I was then very confident that it would work also
on my work pc (XP with python 2.3). It does not, I get the following error

Traceback (most recent call last):
  File
"C:\Python23\Lib\site-packages\pythonwin\pywin\framework\scriptutils.py",
line 310, in RunScript
    exec codeObject in __main__.__dict__
  File "E:\OFDMA_test\iqw.py", line 16, in ?
    x[i/4]=unpack('f',a[i:i+4])[0]
error: unpack str size does not match format


apparently the XP box thinks the file is alot shorter, and that can't be as
it is the same file from the same media (USB stick). What is going wrong
here?


/Johan


import os

from struct import *
from scipy import *



f=file("c:\\tmp\\FSL_good_SNR\\Last_IQ.iqw",'r')
a=f.read()
f.close()

x=zeros(len(a)/4)+0.0

for i in range (0, len(a),4):
    x[i/4]=unpack('f',a[i:i+4])[0]

y=x[0:len(x)/2-1]+1j*x[len(x)/2:len(x)-1]

writer = file("c:\\tmp\\FSL_good_SNR\\IQ.csv", 'w')
for item in y:
    writer.write(repr(real(item))+','+repr(imag(item))+'\n')
writer.close()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20060202/3e30a7b0/attachment.html 


More information about the Tutor mailing list