[SciPy-user] Cookbook/InputOutput

Ryan Krauss ryanlists@gmail....
Sat Oct 27 11:50:50 CDT 2007


Are you trying to do somthing like this:

In [19]: myline = '1.0, 2.0, 3.0, 4.0'

In [20]: mylist = myline.split(',')

In [21]: mylist
Out[21]: ['1.0', ' 2.0', ' 3.0', ' 4.0']

In [22]: mylist = [item.strip() for item in mylist]

In [23]: mylist
Out[23]: ['1.0', '2.0', '3.0', '4.0']

In [24]: myfloats = [float(item) for item in mylist]

In [25]: myfloats
Out[25]: [1.0, 2.0, 3.0, 4.0]


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
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://projects.scipy.org/pipermail/scipy-user/attachments/20071027/0ac3c3db/attachment.html 


More information about the SciPy-user mailing list