Re: [sage-support] How to handle file in Sage

2014-10-28 Thread Santanu Sarkar
Thank you so much.

On 28 October 2014 02:00, William Stein  wrote:

> On Mon, Oct 27, 2014 at 1:24 PM, slelievre 
> wrote:
> > 'load' is expecting filenames with extension among
> >
> >  .py, .sage, .sobj
> >
> > and maybe a few others.
> >
> > If the file name does not have an extension in that short list,
> > 'load' will add the extension .sobj.
> >
>
> Yes, use Python's builtin open command:
>
>   A1 = open("./Documents/program21.txt").read()
>
> >
> > Le lundi 27 octobre 2014 15:12:17 UTC+1, Santanu a écrit :
> >>
> >> Thanks a lot. But I am getting these errors:
> >>
> >> A1=load("./Documents/program21.txt")
> >>
> >>
> >> Traceback (most recent call last):
> >>   File "", line 1, in 
> >>   File "_sage_input_4.py", line 10, in 
> >> exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8
> >> -*-\\n" +
> >>
> _support_.preparse_worksheet_cell(base64.b64decode("QTE9bG9hZCgiLi9Eb2N1bWVudHMvcHJvZ3JhbTIxLnR4dCIp"),globals())+"\\n");
> >> execfile(os.path.abspath("___code___.py"))
> >>   File "", line 1, in 
> >>
> >>   File "/tmp/tmpYQU78_/___code___.py", line 2, in 
> >> exec compile(u'A1=load("./Documents/program21.txt")
> >>   File "", line 1, in 
> >>
> >>   File "sage_object.pyx", line 862, in sage.structure.sage_object.load
> >> (sage/structure/sage_object.c:9317)
> >> IOError: [Errno 2] No such file or directory:
> >> './Documents/program21.txt.sobj'
> >>
> >>
> >>
> >>
> --
> >>
> >>
> >> exec preparse(open('/Documents/program21.txt').read())
> >>
> >>
> >> Traceback (most recent call last):
> >>   File "", line 1, in 
> >>   File "_sage_input_5.py", line 10, in 
> >> exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8
> >> -*-\\n" +
> >>
> _support_.preparse_worksheet_cell(base64.b64decode("ZXhlYyBwcmVwYXJzZShvcGVuKCcvRG9jdW1lbnRzL3Byb2dyYW0yMS50eHQnKS5yZWFkKCkp"),globals())+"\\n");
> >> execfile(os.path.abspath("___code___.py"))
> >>   File "", line 1, in 
> >>
> >>   File "/tmp/tmpqrNaPI/___code___.py", line 2, in 
> >> exec compile(u"exec
> preparse(open('/Documents/program21.txt').read())"
> >> + '\n', '', 'single')
> >>   File "", line 1, in 
> >>
> >> IOError: [Errno 2] No such file or directory: '/Documents/program21.txt'
> >>
> >>
> >> On 22 October 2014 05:56, William Stein  wrote:
> >>>
> >>> On Tue, Oct 21, 2014 at 5:19 PM, kcrisman  wrote:
> >>> >> > differently)
> >>> >>
> >>> >> Thanks - I meant %runfile not %execfile.  I find it hard to
> remember,
> >>> >> which is yet another reason I am against removal of the more
> memorable
> >>> >> %load
> >>> >> that we had for years.
> >>> >>
> >>> >> >
> >>> >>
> >>> >
> >>> > Agreed, but this was semi-unavoidable because of the Ipython upgrade
> a
> >>> > while
> >>> > back, though, right?
> >>>
> >>> It was definitely not unavoidable.
> >>>
> >>> -- William
> >>>
> >>> >
> >>> > --
> >>> > You received this message because you are subscribed to the Google
> >>> > Groups
> >>> > "sage-support" group.
> >>> > To unsubscribe from this group and stop receiving emails from it,
> send
> >>> > an
> >>> > email to sage-support...@googlegroups.com.
> >>> > To post to this group, send email to sage-s...@googlegroups.com.
> >>> > Visit this group at http://groups.google.com/group/sage-support.
> >>> > For more options, visit https://groups.google.com/d/optout.
> >>>
> >>>
> >>>
> >>> --
> >>> William Stein
> >>> Professor of Mathematics
> >>> University of Washington
> >>> http://wstein.org
> >>>
> >>> --
> >>> You received this message because you are subscribed to the Google
> Groups
> >>> "sage-support" group.
> >>> To unsubscribe from this group and stop receiving emails from it, send
> an
> >>> email to sage-support...@googlegroups.com.
> >>> To post to this group, send email to sage-s...@googlegroups.com.
> >>> Visit this group at http://groups.google.com/group/sage-support.
> >>> For more options, visit https://groups.google.com/d/optout.
> >>
> >>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "sage-support" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to sage-support+unsubscr...@googlegroups.com.
> > To post to this group, send email to sage-support@googlegroups.com.
> > Visit this group at http://groups.google.com/group/sage-support.
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> William Stein
> Professor of Mathematics
> University of Washington
> http://wstein.org
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-support@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.
>

--

Re: [sage-support] How to handle file in Sage

2014-10-27 Thread William Stein
On Mon, Oct 27, 2014 at 1:24 PM, slelievre  wrote:
> 'load' is expecting filenames with extension among
>
>  .py, .sage, .sobj
>
> and maybe a few others.
>
> If the file name does not have an extension in that short list,
> 'load' will add the extension .sobj.
>

Yes, use Python's builtin open command:

  A1 = open("./Documents/program21.txt").read()

>
> Le lundi 27 octobre 2014 15:12:17 UTC+1, Santanu a écrit :
>>
>> Thanks a lot. But I am getting these errors:
>>
>> A1=load("./Documents/program21.txt")
>>
>>
>> Traceback (most recent call last):
>>   File "", line 1, in 
>>   File "_sage_input_4.py", line 10, in 
>> exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8
>> -*-\\n" +
>> _support_.preparse_worksheet_cell(base64.b64decode("QTE9bG9hZCgiLi9Eb2N1bWVudHMvcHJvZ3JhbTIxLnR4dCIp"),globals())+"\\n");
>> execfile(os.path.abspath("___code___.py"))
>>   File "", line 1, in 
>>
>>   File "/tmp/tmpYQU78_/___code___.py", line 2, in 
>> exec compile(u'A1=load("./Documents/program21.txt")
>>   File "", line 1, in 
>>
>>   File "sage_object.pyx", line 862, in sage.structure.sage_object.load
>> (sage/structure/sage_object.c:9317)
>> IOError: [Errno 2] No such file or directory:
>> './Documents/program21.txt.sobj'
>>
>>
>>
>> --
>>
>>
>> exec preparse(open('/Documents/program21.txt').read())
>>
>>
>> Traceback (most recent call last):
>>   File "", line 1, in 
>>   File "_sage_input_5.py", line 10, in 
>> exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8
>> -*-\\n" +
>> _support_.preparse_worksheet_cell(base64.b64decode("ZXhlYyBwcmVwYXJzZShvcGVuKCcvRG9jdW1lbnRzL3Byb2dyYW0yMS50eHQnKS5yZWFkKCkp"),globals())+"\\n");
>> execfile(os.path.abspath("___code___.py"))
>>   File "", line 1, in 
>>
>>   File "/tmp/tmpqrNaPI/___code___.py", line 2, in 
>> exec compile(u"exec preparse(open('/Documents/program21.txt').read())"
>> + '\n', '', 'single')
>>   File "", line 1, in 
>>
>> IOError: [Errno 2] No such file or directory: '/Documents/program21.txt'
>>
>>
>> On 22 October 2014 05:56, William Stein  wrote:
>>>
>>> On Tue, Oct 21, 2014 at 5:19 PM, kcrisman  wrote:
>>> >> > differently)
>>> >>
>>> >> Thanks - I meant %runfile not %execfile.  I find it hard to remember,
>>> >> which is yet another reason I am against removal of the more memorable
>>> >> %load
>>> >> that we had for years.
>>> >>
>>> >> >
>>> >>
>>> >
>>> > Agreed, but this was semi-unavoidable because of the Ipython upgrade a
>>> > while
>>> > back, though, right?
>>>
>>> It was definitely not unavoidable.
>>>
>>> -- William
>>>
>>> >
>>> > --
>>> > You received this message because you are subscribed to the Google
>>> > Groups
>>> > "sage-support" group.
>>> > To unsubscribe from this group and stop receiving emails from it, send
>>> > an
>>> > email to sage-support...@googlegroups.com.
>>> > To post to this group, send email to sage-s...@googlegroups.com.
>>> > Visit this group at http://groups.google.com/group/sage-support.
>>> > For more options, visit https://groups.google.com/d/optout.
>>>
>>>
>>>
>>> --
>>> William Stein
>>> Professor of Mathematics
>>> University of Washington
>>> http://wstein.org
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "sage-support" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to sage-support...@googlegroups.com.
>>> To post to this group, send email to sage-s...@googlegroups.com.
>>> Visit this group at http://groups.google.com/group/sage-support.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-support@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.



-- 
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-support] How to handle file in Sage

2014-10-27 Thread slelievre
'load' is expecting filenames with extension among

 .py, .sage, .sobj

and maybe a few others.

If the file name does not have an extension in that short list,
'load' will add the extension .sobj.



Le lundi 27 octobre 2014 15:12:17 UTC+1, Santanu a écrit :
>
> Thanks a lot. But I am getting these errors: 
>
> A1=load("./Documents/program21.txt")
>
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "_sage_input_4.py", line 10, in 
> exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 
> -*-\\n" + 
> _support_.preparse_worksheet_cell(base64.b64decode("QTE9bG9hZCgiLi9Eb2N1bWVudHMvcHJvZ3JhbTIxLnR4dCIp"),globals())+"\\n");
>  
> execfile(os.path.abspath("___code___.py"))
>   File "", line 1, in 
> 
>   File "/tmp/tmpYQU78_/___code___.py", line 2, in 
> exec compile(u'A1=load("./Documents/program21.txt")
>   File "", line 1, in 
> 
>   File "sage_object.pyx", line 862, in sage.structure.sage_object.load 
> (sage/structure/sage_object.c:9317)
> IOError: [Errno 2] No such file or directory: 
> './Documents/program21.txt.sobj'
>
>
>
> --
>
>
> exec preparse(open('/Documents/program21.txt').read())
>
>
> Traceback (most recent call last):
>   File "", line 1, in 
>   File "_sage_input_5.py", line 10, in 
> exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 
> -*-\\n" + 
> _support_.preparse_worksheet_cell(base64.b64decode("ZXhlYyBwcmVwYXJzZShvcGVuKCcvRG9jdW1lbnRzL3Byb2dyYW0yMS50eHQnKS5yZWFkKCkp"),globals())+"\\n");
>  
> execfile(os.path.abspath("___code___.py"))
>   File "", line 1, in 
> 
>   File "/tmp/tmpqrNaPI/___code___.py", line 2, in 
> exec compile(u"exec preparse(open('/Documents/program21.txt').read())" 
> + '\n', '', 'single')
>   File "", line 1, in 
> 
> IOError: [Errno 2] No such file or directory: '/Documents/program21.txt'
>
>
> On 22 October 2014 05:56, William Stein > 
> wrote:
>
>> On Tue, Oct 21, 2014 at 5:19 PM, kcrisman > > wrote:
>> >> > differently)
>> >>
>> >> Thanks - I meant %runfile not %execfile.  I find it hard to remember,
>> >> which is yet another reason I am against removal of the more memorable 
>> %load
>> >> that we had for years.
>> >>
>> >> >
>> >>
>> >
>> > Agreed, but this was semi-unavoidable because of the Ipython upgrade a 
>> while
>> > back, though, right?
>>
>> It was definitely not unavoidable.
>>
>> -- William
>>
>> >
>> > --
>> > You received this message because you are subscribed to the Google 
>> Groups
>> > "sage-support" group.
>> > To unsubscribe from this group and stop receiving emails from it, send 
>> an
>> > email to sage-support...@googlegroups.com .
>> > To post to this group, send email to sage-s...@googlegroups.com 
>> .
>> > Visit this group at http://groups.google.com/group/sage-support.
>> > For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>> --
>> William Stein
>> Professor of Mathematics
>> University of Washington
>> http://wstein.org
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "sage-support" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to sage-support...@googlegroups.com .
>> To post to this group, send email to sage-s...@googlegroups.com 
>> .
>> Visit this group at http://groups.google.com/group/sage-support.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-support] How to handle file in Sage

2014-10-27 Thread Santanu Sarkar
Thanks a lot. But I am getting these errors:

A1=load("./Documents/program21.txt")


Traceback (most recent call last):
  File "", line 1, in 
  File "_sage_input_4.py", line 10, in 
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8
-*-\\n" +
_support_.preparse_worksheet_cell(base64.b64decode("QTE9bG9hZCgiLi9Eb2N1bWVudHMvcHJvZ3JhbTIxLnR4dCIp"),globals())+"\\n");
execfile(os.path.abspath("___code___.py"))
  File "", line 1, in 

  File "/tmp/tmpYQU78_/___code___.py", line 2, in 
exec compile(u'A1=load("./Documents/program21.txt")
  File "", line 1, in 

  File "sage_object.pyx", line 862, in sage.structure.sage_object.load
(sage/structure/sage_object.c:9317)
IOError: [Errno 2] No such file or directory:
'./Documents/program21.txt.sobj'



--


exec preparse(open('/Documents/program21.txt').read())


Traceback (most recent call last):
  File "", line 1, in 
  File "_sage_input_5.py", line 10, in 
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8
-*-\\n" +
_support_.preparse_worksheet_cell(base64.b64decode("ZXhlYyBwcmVwYXJzZShvcGVuKCcvRG9jdW1lbnRzL3Byb2dyYW0yMS50eHQnKS5yZWFkKCkp"),globals())+"\\n");
execfile(os.path.abspath("___code___.py"))
  File "", line 1, in 

  File "/tmp/tmpqrNaPI/___code___.py", line 2, in 
exec compile(u"exec preparse(open('/Documents/program21.txt').read())"
+ '\n', '', 'single')
  File "", line 1, in 

IOError: [Errno 2] No such file or directory: '/Documents/program21.txt'


On 22 October 2014 05:56, William Stein  wrote:

> On Tue, Oct 21, 2014 at 5:19 PM, kcrisman  wrote:
> >> > differently)
> >>
> >> Thanks - I meant %runfile not %execfile.  I find it hard to remember,
> >> which is yet another reason I am against removal of the more memorable
> %load
> >> that we had for years.
> >>
> >> >
> >>
> >
> > Agreed, but this was semi-unavoidable because of the Ipython upgrade a
> while
> > back, though, right?
>
> It was definitely not unavoidable.
>
> -- William
>
> >
> > --
> > You received this message because you are subscribed to the Google Groups
> > "sage-support" group.
> > To unsubscribe from this group and stop receiving emails from it, send an
> > email to sage-support+unsubscr...@googlegroups.com.
> > To post to this group, send email to sage-support@googlegroups.com.
> > Visit this group at http://groups.google.com/group/sage-support.
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> William Stein
> Professor of Mathematics
> University of Washington
> http://wstein.org
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-support@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-support] How to handle file in Sage

2014-10-21 Thread William Stein
On Tue, Oct 21, 2014 at 5:19 PM, kcrisman  wrote:
>> > differently)
>>
>> Thanks - I meant %runfile not %execfile.  I find it hard to remember,
>> which is yet another reason I am against removal of the more memorable %load
>> that we had for years.
>>
>> >
>>
>
> Agreed, but this was semi-unavoidable because of the Ipython upgrade a while
> back, though, right?

It was definitely not unavoidable.

-- William

>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-support+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-support@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.



-- 
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-support] How to handle file in Sage

2014-10-21 Thread kcrisman

>
> > differently)
>
> Thanks - I meant %runfile not %execfile.  I find it hard to remember, 
> which is yet another reason I am against removal of the more memorable 
> %load that we had for years.
>
> >
>
>
Agreed, but this was semi-unavoidable because of the Ipython upgrade a 
while back, though, right?   

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-support] How to handle file in Sage

2014-10-20 Thread William Stein
On Oct 20, 2014 1:20 AM, "John Cremona"  wrote:
>
> On 19 October 2014 20:02, William Stein  wrote:
> > On Sun, Oct 19, 2014 at 4:52 AM, Santanu Sarkar
> >  wrote:
> >> I have a text file abc.txt in Desktop where  I have written
A=[1,2,3,4]. Is
> >> it possible
> >> to call this array A from Sage notebook?
> >>
> >> When I write the following in notebook,
> >>
> >>  A1 = load("/Desktop/abc.txt")
> >
> > You could do this:
> >
> > exec preparse(open('/Desktop/abc.txt').read())
> >
> > or name your file abc.sage and do
> >
> > load('/Desktop/abc.sage')
> >
> > in the notebook (maybe), or
> >
> > %execfile /Desktop/abc.sage
> >
> > on the command line.  (That one has to use %execfile and %load doesn't
> > work continues to be a change that I am unhappy with.)
>
> %runfile abc.sage
>
> works fine, that is what I use all the time.  The extension has to be
> sage or py (or pyx or spyx or m but the would be read / parsed
> differently)

Thanks - I meant %runfile not %execfile.  I find it hard to remember, which
is yet another reason I am against removal of the more memorable %load that
we had for years.

>
> John
> >
> > Published example (requires login still):
> >
> >
https://cloud.sagemath.com/projects/4a5f0542-5873-4eed-a85c-a18c706e8bcd/files/2014-10-19-115550-load/
> >
> >  -- William
> >
> >>
> >> getting
> >>
> >> Traceback (most recent call last):
> >>   File "", line 1, in 
> >>   File "_sage_input_49.py", line 10, in 
> >> exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8
> >> -*-\\n" +
> >>
_support_.preparse_worksheet_cell(base64.b64decode("QTEgPSBsb2FkKCIvRGVza3RvcC9hYmMudHh0Iik="),globals())+"\\n");
> >> execfile(os.path.abspath("___code___.py"))
> >>   File "", line 1, in 
> >>
> >>   File "/tmp/tmpgD_ocu/___code___.py", line 2, in 
> >> exec compile(u'A1 = load("/Desktop/abc.txt")
> >>   File "", line 1, in 
> >>
> >>   File "sage_object.pyx", line 862, in sage.structure.sage_object.load
> >> (sage/structure/sage_object.c:9317)
> >> IOError: [Errno 2] No such file or directory: '/Desktop/abc.txt.sobj'
> >>
> >>
> >> --
> >> You received this message because you are subscribed to the Google
Groups
> >> "sage-support" group.
> >> To unsubscribe from this group and stop receiving emails from it, send
an
> >> email to sage-support+unsubscr...@googlegroups.com.
> >> To post to this group, send email to sage-support@googlegroups.com.
> >> Visit this group at http://groups.google.com/group/sage-support.
> >> For more options, visit https://groups.google.com/d/optout.
> >
> >
> >
> > --
> > William Stein
> > Professor of Mathematics
> > University of Washington
> > http://wstein.org
> >
> > --
> > You received this message because you are subscribed to the Google
Groups "sage-support" group.
> > To unsubscribe from this group and stop receiving emails from it, send
an email to sage-support+unsubscr...@googlegroups.com.
> > To post to this group, send email to sage-support@googlegroups.com.
> > Visit this group at http://groups.google.com/group/sage-support.
> > For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
"sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an
email to sage-support+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-support@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


Re: [sage-support] How to handle file in Sage

2014-10-20 Thread John Cremona
On 19 October 2014 20:02, William Stein  wrote:
> On Sun, Oct 19, 2014 at 4:52 AM, Santanu Sarkar
>  wrote:
>> I have a text file abc.txt in Desktop where  I have written  A=[1,2,3,4]. Is
>> it possible
>> to call this array A from Sage notebook?
>>
>> When I write the following in notebook,
>>
>>  A1 = load("/Desktop/abc.txt")
>
> You could do this:
>
> exec preparse(open('/Desktop/abc.txt').read())
>
> or name your file abc.sage and do
>
> load('/Desktop/abc.sage')
>
> in the notebook (maybe), or
>
> %execfile /Desktop/abc.sage
>
> on the command line.  (That one has to use %execfile and %load doesn't
> work continues to be a change that I am unhappy with.)

%runfile abc.sage

works fine, that is what I use all the time.  The extension has to be
sage or py (or pyx or spyx or m but the would be read / parsed
differently)

John
>
> Published example (requires login still):
>
>
> https://cloud.sagemath.com/projects/4a5f0542-5873-4eed-a85c-a18c706e8bcd/files/2014-10-19-115550-load/
>
>  -- William
>
>>
>> getting
>>
>> Traceback (most recent call last):
>>   File "", line 1, in 
>>   File "_sage_input_49.py", line 10, in 
>> exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8
>> -*-\\n" +
>> _support_.preparse_worksheet_cell(base64.b64decode("QTEgPSBsb2FkKCIvRGVza3RvcC9hYmMudHh0Iik="),globals())+"\\n");
>> execfile(os.path.abspath("___code___.py"))
>>   File "", line 1, in 
>>
>>   File "/tmp/tmpgD_ocu/___code___.py", line 2, in 
>> exec compile(u'A1 = load("/Desktop/abc.txt")
>>   File "", line 1, in 
>>
>>   File "sage_object.pyx", line 862, in sage.structure.sage_object.load
>> (sage/structure/sage_object.c:9317)
>> IOError: [Errno 2] No such file or directory: '/Desktop/abc.txt.sobj'
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "sage-support" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to sage-support+unsubscr...@googlegroups.com.
>> To post to this group, send email to sage-support@googlegroups.com.
>> Visit this group at http://groups.google.com/group/sage-support.
>> For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
> William Stein
> Professor of Mathematics
> University of Washington
> http://wstein.org
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sage-support" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sage-support+unsubscr...@googlegroups.com.
> To post to this group, send email to sage-support@googlegroups.com.
> Visit this group at http://groups.google.com/group/sage-support.
> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.


[sage-support] How to handle file in Sage

2014-10-19 Thread Santanu Sarkar
I have a text file abc.txt in Desktop where  I have written  A=[1,2,3,4].
Is it possible
to call this array A from Sage notebook?

When I write the following in notebook,

 A1 = load("/Desktop/abc.txt")

getting

Traceback (most recent call last):
  File "", line 1, in 
  File "_sage_input_49.py", line 10, in 
exec compile(u'open("___code___.py","w").write("# -*- coding:
utf-8 -*-\\n" +
_support_.preparse_worksheet_cell(base64.b64decode("QTEgPSBsb2FkKCIvRGVza3RvcC9hYmMudHh0Iik="),globals())+"\\n");
execfile(os.path.abspath("___code___.py"))
  File "", line 1, in 

  File "/tmp/tmpgD_ocu/___code___.py", line 2, in 
exec compile(u'A1 = load("/Desktop/abc.txt")
  File "", line 1, in 

  File "sage_object.pyx", line 862, in sage.structure.sage_object.load
(sage/structure/sage_object.c:9317)
IOError: [Errno 2] No such file or directory: '/Desktop/abc.txt.sobj'

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-support+unsubscr...@googlegroups.com.
To post to this group, send email to sage-support@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.