[SciPy-user] Cookbook/InputOutput

Nils Wagner nwagner@iam.uni-stuttgart...
Sat Oct 27 13:21:51 CDT 2007


On Sat, 27 Oct 2007 11:49:01 -0500
  "Ryan Krauss" <ryanlists@gmail.com> wrote:
> help split gives this:
> 
> split(ary, indices_or_sections, axis=0)
>    Divide an array into a list of sub-arrays.
> 
>    Description:
>       Divide ary into a list of sub-arrays along the
>       specified axis.  If indices_or_sections is an 
>integer,
>       ary is divided into that many equally sized 
>arrays.
>       If it is impossible to make an equal split, an 
>error is
>       raised.  This is the only way this function 
>differs from
>       the array_split() function. If indices_or_sections 
>is a
>       list of sorted integers, its entries define the 
>indexes
>       where ary is split.
> 
> 
> On 10/26/07, Nils Wagner <nwagner@iam.uni-stuttgart.de> 
>wrote:
>>
>> Hi all,
>>
>> I tried to use the home-made function
>> (available at http://www.scipy.org/Cookbook/InputOutput)
>> to read an array from the file topo-28.xohis
>> (See attachment for details).
>>
>> If I run the script (xy.py) I get
>>
>> python -i xy.py
>> Traceback (most recent call last):
>>    File "xy.py", line 47, in ?
>>      data = readArray("topo-28.xohis")
>>    File "xy.py", line 35, in readArray
>>      items = split(stripped_line)
>> TypeError: split() takes at least 2 arguments (1 given)
>>
>> How can I fix the problem ?
>>
>> Any pointer would be appreciated.
>>
>> Thanks in advance
>>
>>                        Nils
>>
>> _______________________________________________
>> SciPy-user mailing list
>> SciPy-user@scipy.org
>> http://projects.scipy.org/mailman/listinfo/scipy-user
>>
>>
>>

There are two different split functions.
Finally I have used
from string import lstrip,split #
Now python xy.py works for me :-).

Cheers,
          Nils

Help on function split in module string:

split(s, sep=None, maxsplit=-1)
     split(s [,sep [,maxsplit]]) -> list of strings

     Return a list of the words in the string s, using sep 
as the
     delimiter string.  If maxsplit is given, splits at no 
more than
     maxsplit places (resulting in at most maxsplit+1 
words).  If sep
     is not specified or is None, any whitespace string is 
a separator.

     (split and splitfields are synonymous)
  


More information about the SciPy-user mailing list