Chris Colbert wrote:
> what machine spec are you using?
Dual 2Ghz PPC OS-X 10.4. Python2.5, numpy 1.3.0rc1 (hmm -- I should
upgrade that!)
> Using your last function line2array5 WITH float conversion, i get the
> following timing on a mobile quad core extreme:
>
> In [24]: a = np.arange(100).a
what machine spec are you using?
Using your last function line2array5 WITH float conversion, i get the
following timing on a mobile quad core extreme:
In [24]: a = np.arange(100).astype(str).tostring()
In [25]: a
Out[25]:
'012345678911223344556677
Hi all,
When I first saws this problem: reading in a fixed-width text file as
numbers, it struck me that you really should be able to do it, and do it
well, with numpy by slicing character arrays.
I got carried away, and worked out a number of ways to do it. Lastly was
a method inspired by a
By the way, Chris, what's it gonna take to get you contributing to the doc? ;-)
DG
--- On Wed, 7/22/09, Christopher Barker wrote:
> From: Christopher Barker
> Subject: Re: [Numpy-discussion] String manipulation
> To: "Discussion of Numerical Python"
> Date: Wedn
Stéfan van der Walt wrote:
You cannot use view on an array scalar, so you'll have to convert to
an array first:
x = x.reshape((1,))
x.view('S1')
Bingo!
Thanks, Stéfan.
I don't know why one can't uwe view on a scalar -- there is still a dat
pointer isn't there?, and it can be reshaped. Butno
2009/7/21 Christopher Barker :
> In [35]: line
> Out[35]: '-1.00E+00-1.00E+00-1.00E+00-1.00E+00
> 1.25E+00 1.25E+00'
>
> In [36]: a = np.array(line)
>
> In [37]: a
> Out[37]:
> array('-1.00E+00-1.00E+00-1.00E+00-1.00E+00 1.25E+00
> 1.25E+00',
>
--- On Tue, 7/21/09, Christopher Barker wrote:
> but now when I try to split it up:
>
> In [38]: a = a.view(dtype='S13')
>
> I get:
>
> ValueError: new type not compatible with array.
>
> Shouldn't that work?
>
> -Chris
Submit an enhancement ticket. ;-)
DG
___
David Goldsmith wrote:
> Hi, Chris. Look at this, _I'm_ answering one of _your_ questions
> (correctly, I hope):
maybe ;-)
> --- On Tue, 7/21/09, Christopher Barker
> wrote:
>> I don't see why:
>>
>> np.array('a string', dtype='S1')
>>
>> results in a length (1,) array, for instance.
> Well,
Hi, Chris. Look at this, _I'm_ answering one of _your_ questions (correctly, I
hope):
--- On Tue, 7/21/09, Christopher Barker wrote:
> I don't see why:
>
> np.array('a string', dtype='S1')
>
> results in a length (1,) array, for instance.
>
> Actually, I think I do -- numpy is treating the
Pierre GM wrote:
> On Jul 20, 2009, at 3:44 PM, Christopher Barker wrote:
>> ...
>> Is there a cleaner way to do this?
> Yes. np.lib._iotools.LineSplitter and/or np.genfromtxt
Great, thanks -- though the underscore in _iotools implies that this
isn't supposed to be general purpose tools.
Also,
On Jul 21, 2009, at 3:16 AM, Nils Wagner wrote:
>>
>> Er, there's already something like that:
>> np.lib._iotools.LineSplitter
>
> Great. I didn't know about that.
>
> Your examples are very useful.
>
> IMHO the examples should be added to
>
> http://www.scipy.org/Cookbook/InputOutput
>
> to attra
On Tue, 21 Jul 2009 02:56:28 -0400
Pierre GM wrote:
>
> On Jul 21, 2009, at 2:42 AM, Nils Wagner wrote:
>>
>> Fixed-length fields are quite common e.g. in the area of
>> Finite Element pre/postprocessing.
>> Therefore It would be nice to have a function like
>> line2array in numpy.
>> Comments
On Jul 20, 2009, at 3:44 PM, Christopher Barker wrote:
> ...
> Is there a cleaner way to do this?
>
> -Chris
Yes. np.lib._iotools.LineSplitter and/or np.genfromtxt
___
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailma
On Jul 21, 2009, at 2:42 AM, Nils Wagner wrote:
>
> Fixed-length fields are quite common e.g. in the area of
> Finite Element pre/postprocessing.
> Therefore It would be nice to have a function like
> line2array in numpy.
> Comments ?
Er, there's already something like that:
np.lib._iotools.LineS
On Mon, 20 Jul 2009 12:44:23 -0700
Christopher Barker wrote:
> Nils Wagner wrote:
>> How can I split the second line in such a way that I get
>>
>> ['-1.00E+00', '-1.00E+00', '-1.00E+00',
>> '-1.00E+00', '1.25E+00', '1.25E+00']
>>
>> instead of
>>
>> ['-1.00E+00-1
Nils Wagner wrote:
How can I split the second line in such a way that I get
['-1.00E+00', '-1.00E+00', '-1.00E+00',
'-1.00E+00', '1.25E+00', '1.25E+00']
instead of
['-1.00E+00-1.00E+00-1.00E+00-1.00E+00',
'1.25E+00', '1.25E+00']
It looks lik
On Mon, 11 May 2009 10:48:14 -0400
Alan G Isaac wrote:
> On 5/11/2009 8:36 AM Nils Wagner apparently wrote:
>> I would like to split strings made of digits after eight
>> characters each.
>
>
> [l[i*8:(i+1)*8] for i in range(len(l)/8)]
>
> Alan Isaac
>
>
On 5/11/2009 8:36 AM Nils Wagner apparently wrote:
> I would like to split strings made of digits after eight
> characters each.
[l[i*8:(i+1)*8] for i in range(len(l)/8)]
Alan Isaac
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://
On 5/11/2009 8:03 AM Nils Wagner apparently wrote:
line_a
> '12345678abcdefgh12345678'
> Is it possible to split line_a such that the output
> is
>
> ['12345678', 'abcdefgh', '12345678']
More of a comp.lang.python question, I think:
out = list()
for k, g in groupby('123abc456',lambda x: x.
hi,
> here is my workaround.
>
> from numpy import arange
> line_a = '11.122.233.3' # without
> separator
> line_b = '11.1 22.2 33.3' # including space
> as a delimiter
>
> div, mod = divmod(len(line_a),8)
> liste = []
> for j in arange(0,div):
> liste.append(li
On Mon, 11 May 2009 15:03:02 +0200
Sebastien Binet wrote:
> On Monday 11 May 2009 14:36:17 Nils Wagner wrote:
>> On Mon, 11 May 2009 14:25:46 +0200
>>
>> Francesc Alted wrote:
>> > A Monday 11 May 2009, Nils Wagner escrigué:
>> >> Hi all,
>> >>
>> >> Please consider two strings
>> >>
>> >> >>
On Monday 11 May 2009 14:36:17 Nils Wagner wrote:
> On Mon, 11 May 2009 14:25:46 +0200
>
> Francesc Alted wrote:
> > A Monday 11 May 2009, Nils Wagner escrigué:
> >> Hi all,
> >>
> >> Please consider two strings
> >>
> >> >>> line_a
> >>
> >> '12345678abcdefgh12345678'
> >>
> >> >>> line_b
> >>
On Mon, 11 May 2009 14:25:46 +0200
Francesc Alted wrote:
> A Monday 11 May 2009, Nils Wagner escrigué:
>> Hi all,
>>
>> Please consider two strings
>>
>> >>> line_a
>>
>> '12345678abcdefgh12345678'
>>
>> >>> line_b
>>
>> '12345678 abcdefgh 12345678'
>>
>> >>> line_b.split()
>>
>> ['12345678', 'a
A Monday 11 May 2009, Francesc Alted escrigué:
> Although regular expressions seems a bit thought to learn, they will
^^^ --> tough :-\
--
Francesc Alted
"One would expect people to feel threatened by the 'giant
brains or machines that think'. In
A Monday 11 May 2009, Nils Wagner escrigué:
> Hi all,
>
> Please consider two strings
>
> >>> line_a
>
> '12345678abcdefgh12345678'
>
> >>> line_b
>
> '12345678 abcdefgh 12345678'
>
> >>> line_b.split()
>
> ['12345678', 'abcdefgh', '12345678']
>
> Is it possible to split line_a such that the output
Hi all,
Please consider two strings
>>> line_a
'12345678abcdefgh12345678'
>>> line_b
'12345678 abcdefgh 12345678'
>>> line_b.split()
['12345678', 'abcdefgh', '12345678']
Is it possible to split line_a such that the output
is
['12345678', 'abcdefgh', '12345678']
Nils
A Thursday 23 April 2009, Nils Wagner escrigué:
> Hi all,
>
> How can I obtain the position of the minus sign within the
> following string ?
>
> >>> liste[1]
>
> '1.5-te'
That's easy by using basic weaponery in Python:
In [8]: liste[1].find('-')
Out[8]: 3
In [9]: liste[1][3]
Out[9]: '-'
--
F
Hi all,
How can I obtain the position of the minus sign within the
following string ?
>>> liste[1]
'1.5-te'
Nils
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion
28 matches
Mail list logo