Welcome!
This is the community forum for my apps Pythonista and Editorial.
For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.
Converting "*.dat" to array...
-
Converting "*.dat" to array...
I have imported "banana.dat" data file to pythonista... i want to convert it to array using following code...
from numpy import * DataIn = loadtxt('banana.dat')
But, I got error...I don not know what is the problem.
-
What's the error?
-
Could not convert string to float: @relation
-
Copy the full stack, please. Are you on the beta, or on 2.0
-
@Webmaster4o said:
stack
Thank you for your quick answers.
The header is:
@relation banana
@attribute At1 real[-3.09,2.81]
@attribute At2 real[-2.39,3.19]
@attribute Class {-1.0,1.0}
@inputs At1, At2
@outputs Class
@data
1.14,-0.114,-1.0
-1.52,-1.15,1.0
-1.05,0.72,-1.0
-0.916,0.397,1.0
-1.09,0.437,1.0
-0.584,0.0937,1.0
1.83,0.452,-1.0
-1.25,-0.286,1.0
1.7,1.21,1.0
-0.482,-0.485,1.0
1.79,-0.459,-1.0I'm using the version 2.0...Maybe the problem is the header...how can I remove the deader?
-
You can ignore the lines starting with
@
by passing acomments
argument toloadtxt
. You also need to specify the delimiter, which is a comma in your case, but whitespace by default. This should work:from numpy import * data = loadtxt('banana.dat', comments='@', delimiter=',')
-
Thank you very much indeed...it works.
-
Of course, my most sarcastic answer would be this
-
@Webmaster4o LOL...you have too much time on your hands
-
:) usually I do use your sarcastic way:D This time, I just wanted to find the answer more qickly.