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

2014-01-15 Thread Hedieh Ebrahimi
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

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

2014-01-15 Thread Daπid
On 15 January 2014 11:12, Hedieh Ebrahimi hedieh.ebrah...@amphos21.comwrote: I try to print my fileContent array after I read it and it looks like this : [b'C:UsersDocumentsProjectmytextfile1.txt' b'C:UsersDocumentsProjectmytextfile2.txt'

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

2014-01-15 Thread Julian Taylor
On 01/15/2014 11:25 AM, Daπid wrote: On 15 January 2014 11:12, Hedieh Ebrahimi hedieh.ebrah...@amphos21.com mailto:hedieh.ebrah...@amphos21.com wrote: I try to print my fileContent array after I read it and it looks like this :

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

2014-01-15 Thread Julian Taylor
On 01/15/2014 01:38 PM, Julian Taylor wrote: On 01/15/2014 11:25 AM, Daπid wrote: On 15 January 2014 11:12, Hedieh Ebrahimi hedieh.ebrah...@amphos21.com ... for utf 8 data: d = np.loadtxt(file, dtype='utf8') ups this is a very bad example as we can't have utf8 as its variable length,

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

2014-01-15 Thread Chris Barker
On Wed, Jan 15, 2014 at 4:38 AM, Julian Taylor jtaylor.deb...@googlemail.com wrote: I try to print my fileContent array after I read it and it looks like this : [b'C:UsersDocumentsProjectmytextfile1.txt'

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

2014-01-15 Thread Charles R Harris
On Wed, Jan 15, 2014 at 10:27 AM, Chris Barker chris.bar...@noaa.govwrote: On Wed, Jan 15, 2014 at 4:38 AM, Julian Taylor jtaylor.deb...@googlemail.com wrote: I try to print my fileContent array after I read it and it looks like this :

Re: [Numpy-discussion] adding more unicode dtypes

2014-01-15 Thread Julian Taylor
On 15.01.2014 18:57, Charles R Harris wrote: ... There was a discussion of this long ago and UCS-4 was chosen as the numpy standard. There are just too many complications that arise in supporting both. my guess is that that discussion was before python3 and you could still simply treat

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

2014-01-15 Thread Chris Barker
On Wed, Jan 15, 2014 at 9:57 AM, Charles R Harris charlesr.har...@gmail.com wrote: There was a discussion of this long ago and UCS-4 was chosen as the numpy standard. There are just too many complications that arise in supporting both. fair enough -- but loadtxt appears to be broken just

Re: [Numpy-discussion] adding more unicode dtypes

2014-01-15 Thread Chris Barker
Julian -- beat me to it! On Wed, Jan 15, 2014 at 10:25 AM, Julian Taylor jtaylor.deb...@googlemail.com wrote: On 15.01.2014 18:57, Charles R Harris wrote: There was a discussion of this long ago and UCS-4 was chosen as the numpy standard. There are just too many complications that arise in

Re: [Numpy-discussion] using loadtxt to load a text file in to a numpy array (Charles R Harris)

2014-01-15 Thread David Goldsmith
On Wed, Jan 15, 2014 at 9:52 AM, numpy-discussion-requ...@scipy.org wrote: Date: Wed, 15 Jan 2014 10:57:51 -0700 From: Charles R Harris charlesr.har...@gmail.com Subject: Re: [Numpy-discussion] using loadtxt to load a text file in to a numpy array To: Discussion of Numerical Python

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

2014-01-15 Thread Chris Barker
bump back to the OP: On Wed, Jan 15, 2014 at 2:12 AM, Hedieh Ebrahimi hedieh.ebrah...@amphos21.com wrote: fileContent=loadtxt(filePath,dtype=str) do either of these work for you? fileContent=loadtxt(filePath,dtype='S') or fileContent=loadtxt(filePath,dtype=np.unicode) -Chris --

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

2014-01-15 Thread Julian Taylor
On 16.01.2014 00:42, Chris Barker wrote: bump back to the OP: On Wed, Jan 15, 2014 at 2:12 AM, Hedieh Ebrahimi hedieh.ebrah...@amphos21.com mailto:hedieh.ebrah...@amphos21.com wrote: fileContent=loadtxt(filePath,dtype=str) do either of these work for you?

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

2014-01-15 Thread Oscar Benjamin
On 15 January 2014 12:38, Julian Taylor jtaylor.deb...@googlemail.com wrote: On 01/15/2014 11:25 AM, Daπid wrote: On 15 January 2014 11:12, Hedieh Ebrahimi hedieh.ebrah...@amphos21.com mailto:hedieh.ebrah...@amphos21.com wrote: I try to print my fileContent array after I read it and it

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

2014-01-15 Thread Chris Barker
On Wed, Jan 15, 2014 at 3:58 PM, Julian Taylor jtaylor.deb...@googlemail.com wrote: fileContent=loadtxt(filePath,dtype='S') this gives you bytes not a string, this can only be fixed by adding new dtypes, or changing the behavior or dtype 'S', but yes, the other thread. But the OP's