This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Garbage output to file of specific size
Type: Stage:
Components: Windows Versions: Python 2.4
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: loewis, mculbert
Priority: normal Keywords:

Created on 2007-01-08 20:40 by mculbert, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
Thresh3DArray_SMDS.py mculbert, 2007-01-08 20:40 Sample script
Messages (3)
msg30956 - (view) Author: Michael Culbertson (mculbert) Date: 2007-01-08 20:40
The attached script inexplicably fills the output file with garbage using the input file available at:

http://cs.wheaton.edu/~mculbert/StdDetVol_Scaled_SMDS.dat (4.6Mb)

If the string outputed in line 26 is changed to f.write("bla "), the output file is legible.  If the expression is changed from f.write("%g " % k) to f.write("%f " % k) or f.write("%e " % k), the file is legible.  If, however, the expression is changed to f.write('x'*len(str(k))+" "), the file remains illegible.  Adding a print statement:

   print "%g " % k 

before line 26 indicates that k is assuming the correct values and that the string interpolation is functioning properly.  This suggests that the problem causing the garbage may be related to the specific file size created with this particular set of data.

The problem occurs with Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit (Intel)] under Windows XP.  The problem doesn't occur with the same script and input file using Python 2.3.5 on Mac OS 10.4.8. 
msg30957 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2007-01-09 18:31
Can you please report what the expected output is? Mine (created on Linux) starts with

40 40 32 64

followed by many "0.0 " values.

Also, can you please report what the actual output is that you get? In what way is it
"illegible"?

What version of Numeric are you using?
msg30958 - (view) Author: Michael Culbertson (mculbert) Date: 2007-01-19 00:41
After some more observation, I've decided this is probably a Windows XP issue, not a Python one.  I transfered the illegible file to a unix machine and was able to read it appropriately, so the python output itself seems to be fine.  Sorry for the trouble.
History
Date User Action Args
2022-04-11 14:56:22adminsetgithub: 44431
2007-01-08 20:40:57mculbertcreate