[Numpy-discussion] using loadtxt to load a text file in to a numpy array

Hedieh Ebrahimi hedieh.ebrahimi at amphos21.com
Wed Jan 15 05:12:42 EST 2014


I am trying to use the following line of code :


in order to load a text file located at path= filePath in to a numpy array
called fileContent.

I´ve simplifed my file for the purpose of this question but the file looks
something like this:

file Content :




I try to print my fileContent array after I read it and it looks like this :


Why is this happening and how can I prevent it ?
Also if I have a line that starts like this in my file, python will crash
on me. how can i fix this ?

!--Timestep  ( line in file starting with !-- )

I guess it has to have something to do with datatype. if I donot define the
datatype it will be float by default which will give me an error an if I
define the datatype as string as I did above, then I get to the problems
that I mentioned above.

I´d appreciate any help on how to fix this.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140115/bcfedc55/attachment.html>

More information about the NumPy-Discussion mailing list