Hello,

I am trying to use the following line of code :


fileContent=loadtxt(filePath,dtype=str)

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 :

C:\Users\Documents\Project\mytextfile1.txt

C:\Users\Documents\Project\mytextfile2.txt

C:\Users\Documents\Project\mytextfile3.txt

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

["b'C:\\\\Users\\\\Documents\\\\Project\\\\mytextfile1.txt'"
 "b'C:\\\\Users\\\\Documents\\\\Project\\\\mytextfile2.txt'"
 "b'C:\\\\Users\\\\Documents\\\\Project\\\\mytextfile3.txt'"]

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.

Thanks
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to