[Numpy-discussion] Appending a numpy array to binary file

Alessandro alessandro.sanginario@polito...
Tue Mar 22 05:37:18 CDT 2011


Hi everybody,
I'm trying to append, inside a loop, into a binary file some arrays using 
 numpy.save(file, arr) but wvhen I open it there is only the last array I 
saved.
If I use savetxt it works perfectly. Do you know how can I append data to a 
binary file inside a loop?

Example:

x = arange(10)
fp = open("TempFile","ab")
for i in range(3):
	save(fp,x)

fp.close()

Data saved into the file is: [0,1,2,3,4,5,6,7,8,9] but I would like: 
[0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9 0,1,2,3,4,5,6,7,8,9]

Thank you.


-- 
------------------------------------------------------------------------------
               Alessandro Sanginario
	
	        Politecnico di Torino
	   Department of Electronics
	   C.so Duca degli Abruzzi, 24
	         10129 Torino - Italy
	        
	        Tel. +39 0115644151
	        Fax. +39 0115644099
	        Skype: sangiox
------------------------------------------------------------------------------
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/numpy-discussion/attachments/20110322/6cee991c/attachment.html 


More information about the NumPy-Discussion mailing list