Ask Your Question

npa's profile - activity

2015-10-28 04:38:21 -0500 received badge  Good Question (source)
2015-10-08 08:52:44 -0500 received badge  Famous Question (source)
2014-05-29 23:18:49 -0500 received badge  Notable Question (source)
2013-08-29 05:13:41 -0500 received badge  Famous Question (source)
2013-08-06 00:17:56 -0500 received badge  Popular Question (source)
2013-05-05 21:24:49 -0500 received badge  Notable Question (source)
2013-02-27 04:37:00 -0500 received badge  Popular Question (source)
2012-10-06 14:50:16 -0500 asked a question Is it possible to convert Mathematica notebook to Sage?

I have been using Mathematica, now would like to switch to Sage. Is there a way that I can convert my existing Mathematica notebooks to Sage?

2012-10-06 03:55:30 -0500 received badge  Scholar (source)
2012-10-06 03:55:30 -0500 marked best answer How to plot data from a file?

Suppose that you have a file '/tmp/DataFile' containing the following text

3;2
2;1
1;0.1
0.01;-0.9

Then you can load the two data columns into two arrays xArr and yArr by the following code

f = open('/home/tobi/tmp/DataFile', 'r')

xArr=[]
yArr=[]
line=f.readline()
while(line !=''): 
    xy=line.split(';')
    xArr.append(float(xy[0]))
    yArr.append(float(xy[1]))
    line=f.readline()

Now you can do whatever you want with these array, for example plot them

list_plot(zip(xArr,yArr))

If you like to understand better what open and readline does look at Python doc input output, the split command is explained in the Python doc on strings

2012-10-05 04:20:43 -0500 received badge  Nice Question (source)
2012-10-05 01:06:56 -0500 received badge  Student (source)
2012-10-04 23:28:03 -0500 asked a question How to plot data from a file?

Is it possible to plot data imported from an ASCII file.

2012-10-04 23:14:01 -0500 received badge  Supporter (source)