14
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Numpy】savetxt()をappendモードで呼び出す

Last updated at Posted at 2014-12-11

What's this

ndarrayをファイルに保存する関数savetxt()をappendモードで行う方法。

#コード

savetxt.py
import numpy

a = [[3, 4, 5], [6, 7, 8], [9, 10, 11]]
nda = numpy.array(a)

a2 = [[-3, -4, -5], [-6, -7, -8], [-9, -10, -11]]
nda2 = numpy.array(a2)

with open('output.txt', 'a') as f_handle:
	numpy.savetxt(f_handle, nda)
	numpy.savetxt(f_handle, nda2)

#参考
http://stackoverflow.com/questions/17731419/appending-a-matrix-to-an-existing-file-using-numpy
http://stackoverflow.com/questions/19793692/strings-and-arraysmatrix-row-wise-numpy-savetxt

14
11
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
11

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?