Advertisement
Guest User

Untitled

a guest
Feb 11th, 2016
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. 1 0 0
  2. 0 0 1
  3. 0 0 1
  4.  
  5. 1 0 0
  6. 0 0 1
  7. 0 0 1 0
  8.  
  9. def addTo(array,textFile):
  10. file=open(textFile,'ab')
  11. (numRows,numColumns)=array.shape
  12. main=array[0:numRows-1,:]
  13. endRow=array[numRows-1,:]
  14. newEndRow=np.append(endRow, [0])
  15. np.savetxt(file,main, fmt='%10.5f', newline=os.linesep)
  16. np.savetxt(file,newEndRow, fmt='%10.5f', newline=os.linesep)
  17. file.close()
  18.  
  19. addTo(np.eye(3),'test1.txt')
  20.  
  21. 1.00000 0.00000 0.00000
  22. 0.00000 1.00000 0.00000
  23. 0.00000
  24. 0.00000
  25. 1.00000
  26. 0.00000
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement