Read an array from a file using io.read_array
![](https://secure.gravatar.com/avatar/612395b66b3e7959997007b342b3688a.jpg?s=120&d=mm&r=g)
Hi all, Is it possible to use io.read_array for the following task. I have an ascii file realeig.pmat. The essential information in this file is a table with 4 columns and several lines corresponding to the number of computed eigenvalues. The task is to read that information from a file. Empty lines and lines beginning with "!", "$" should be skipped. How can I handle the delimiter "&" which is used to continue lines ? Any pointer would be appreciated. Nils
![](https://secure.gravatar.com/avatar/612395b66b3e7959997007b342b3688a.jpg?s=120&d=mm&r=g)
On Thu, 22 Nov 2007 11:04:04 -0500 Alan G Isaac <aisaac@american.edu> wrote:
On Thu, 22 Nov 2007, Nils Wagner apparently wrote:
Is it possible to use io.read_array for the following task.
I think you want numpy.loadtxt
Cheers, Alan Isaac
_______________________________________________ SciPy-user mailing list SciPy-user@scipy.org http://projects.scipy.org/mailman/listinfo/scipy-user
loadtxt(fname, dtype=<type 'float'>, comments='#', delimiter=None, converters=None, skiprows=0, usecols=None, unpack=False) Can I use more than one character to filter out comment lines starting with "!" or "$" ? e.g. comments='!$' Nils
![](https://secure.gravatar.com/avatar/39916bae984cb93b797efd2b175f59c0.jpg?s=120&d=mm&r=g)
On Thu, 22 Nov 2007 11:04:04 -0500 Alan wrote:
I think you want numpy.loadtxt
On Thu, 22 Nov 2007, Nils Wagner apparently wrote:
Can I use more than one character to filter out comment lines starting with "!" or "$" ? e.g. comments='!$'
As long as all comments start in the same way and these two characters always start comments sequentially, no problem. But I think you are saying there are two **different** comment characters? Then you will have to filter comments yourself. Cheers, Alan Isaac
participants (2)
-
Alan G Isaac
-
Nils Wagner