import an array in python

后端 未结 5 1950
清歌不尽
清歌不尽 2020-12-28 19:13

How can I import an array to python (numpy.arry) from a file and that way the file must be written if it doesn\'t already exist.

For example, save out a matrix to a

5条回答
  •  既然无缘
    2020-12-28 20:12

    Another option is numpy.genfromtxt, e.g:

    import numpy as np
    data = np.genfromtxt("myfile.dat",delimiter=",")
    

    This will make data a numpy array with as many rows and columns as are in your file

提交回复
热议问题