I am using Cantor instead of the command line. Here is the issue I come up 
with when trying to save to a file.

Code:
 
import csv

o= open('test.​csv','wb')

output=csv.writer(o)
a = 100

p = list(str(n(pi, digits = a)))

p.remove('.')

p = [int(i) for i in p]

for r in p: output.writerow(r)

del o


Error:

 ------------------------------------------------------------
File "<ipython console>", line 2
del o
^
SyntaxError: invalid syntax


also the same error if I use o.close()


I think I am not closing the for loop correctly? Am I correct?


On Sunday, March 25, 2012 3:21:23 AM UTC-7, Vincent Knight wrote:
>
> Hi all,
>
> I've had trouble with this for a while.
>
> If I write the following in to a notebook cell:
>
> ------
> import csv
>
> output=csv.writer(open('test.csv','wb'))
>
> data=[[1,2],[3,4],[5,6]]
>
> for r in data:
>     output.writerow(r)
>
> -----
>
>
> and evaluate, a hyperlink appears entitled 'test.csv', if I open that csv 
> file it is empy. Checking the code in bash mode in sage (and python) does 
> however work (and create the required csv file). 
>
> Am I missing something to do with the notebook? 
>
> Thanks,
> Vince
>
> PS I've tried this on the notebook running on my machine and sagenb as 
> well...
>
> -- 
> Dr Vincent Knight
> Cardiff School of Mathematics
> Senghennydd Road,
> Cardiff
> CF24 4AG
> (+44) 29 2087 5548
> www.vincent-knight.com
> @drvinceknight <http://twitter.com/#%21/drvinceknight>
> Skype: drvinceknight
>
> 

-- 
To post to this group, send email to sage-support@googlegroups.com
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/sage-support
URL: http://www.sagemath.org

Reply via email to