On Jan 23, 2008 2:39 AM, David R. Kohel <[EMAIL PROTECTED]> wrote:
> Hi John and William,
>
> In my last message, it appears that the non-ASCII characters where
> remapped to ASCII so that you may have to try cutting say from the
> original text on the web page to recreate the problem.
>
> import urllib2
> txt_fr =
> urllib2.urlopen('http://iml.univ-mrs.fr/~kohel/tch/ISARC/chapitre.1.txt').read()
>
> Another option might be pycurl, but it doesn't seem to be included
> in the Python distribution of SAGE.
Use the command get_remote_file:
sage: s =
open(get_remote_file('http://iml.univ-mrs.fr/~kohel/tch/ISARC/chapitre.1.txt')).read()
sage: s[:100]
"Chapitre I\nMarseille - L'arriv\xe9e\n\nLe 24 f\xe9vrier 1815, la
vigie de Notre-Dame de la Garde signala le\n"
>
> The other option which some students tried was the upload a file
> using Data. It indeed uploads the file to a text cell, but we were
> unable to find out how one accesses it.
Upload it then access it by typing
open(DATA + 'chapitre.1.txt').read()
This DATA variable is documented in line three if you click on the Help button
in the upper right of the worksheet. It would also be good if it appeared any
time you upload a file in the confirmation message -- it doesn't right
now. I'll
make a ticket to add this (which will be very easy).
> There is an option to make
> a linked copy to a worksheet which we tried, but, for example,
>
> txt_fr = open("chapitre.1.txt").read()
>
> still fails. Indeed chapitre.1.txt appears as an item in the drop
> down menu under Data, but selecting it just passes one to a new
> buffer.
>
> William, I can report the cut-and-paste of non-ASCII text as a bug
> to sage-trac, but am vague about how or what to report as a bug for
> the file access.
This was related to:
> > > We also failed to get French plaintext into sage, since the
> > > browser interface choked on the cut-and-paste.
Try pasting into the "Edit" mode (the edit tab in the right top-ish side of the
notebook).
-- William
>
>
> --David
>
> On Tue, Jan 22, 2008 at 11:33:28PM -0500, John Voight wrote:
> > Hi David!
> >
> > What a comedy of errors!
> >
> > > We failed completely with file access:
> > >
> > > txt = open("blackcat.txt").read()
> > > txt = open("C:\blackcat.txt").read()
> > >
> > > and other variants (file not found). We had to resort to
> > > cut-and-paste for data entry. Do you have any idea how to read
> > > file downloaded to the windows disk or otherwise get access to
> > > files on the system? Is it possible to open an http port
> > > directly?
> >
> > Apparently the VMware Player cannot access files from outside. Of
> > course this would work fine if the file was located from within the
> > local filesystem. If you login as "manage", you can do a scp to get
> > the files that you need, and then load and open will work OK. Could
> > that be a reasonable substitute?
> >
> > > We also failed to get French plaintext into sage, since the
> > > browser interface choked on the cut-and-paste. I had the idea
> > > of having them compare English and French plaintexts, but we
> > > had to just operate on enciphering the English. I had no problem
> > > with reading the file into sage on my office Mac, and its not
> > > a problem with Python. But I don't know if the cut-and-paste
> > > problem was a sage or windows issue. There is also a menu item
> > > (found by some students) for uplowading a file. But nobody
> > > figured out how to transfer the uploaded text into sage.
> >
> > (You've asked William about this?) I'm a little confused about what
> > French plaintext you're trying to get into Sage and how. Could you
> > say again what you're doing? You have a plaintext file which you'd
> > like to paste into Sage? Because the function names are in English or
> > something?
> >
> > Yours,
> >
> > John Voight
> > Assistant Professor of Mathematics
> > University of Vermont
> > [EMAIL PROTECTED]
> > [EMAIL PROTECTED]
> > http://www.cems.uvm.edu/~voight/
>
--
William Stein
Associate Professor of Mathematics
University of Washington
http://wstein.org
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---