First time here? Check out the FAQ!

Ask Your Question
1

Problem when reading file

asked 10 years ago

thelpt234 gravatar image

Hi,

I am new to sage and there is a simple thing that does not work. I am working in GAP using the Sage notebook. I uploaded a file, called test.txt. Now, I want to run it into my worksheet. I select GAP, then run

Read("DATA+'test.txt'"); m1:=[[E(3),0],[0,E(3)^2]]; m:=Group(m1); Supfast(m,[m1]);

Where Supfast is a function defined in test.txt. I know that the program works because it works when I just copy/paste the code in test.txt. But it does not work when I want to read the file. What is the problem? Thanks in advance!

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
1

answered 10 years ago

Indeed, GAP is not Python, and '+' does not work for concatenating strings in GAP. It has a function that does concatenation:

gap> Concatenation("bla","foo");

"blafoo"

Preview: (hide)
link

Comments

Good to know! But would it recognize DATA in any case?

kcrisman gravatar imagekcrisman ( 10 years ago )

if DATA was set to something like "mydir/" then yes...

Dima gravatar imageDima ( 10 years ago )

Hmm, but DATAis set in the notebook already - in Python. How would GAP find it? (I mean, what syntax?)

kcrisman gravatar imagekcrisman ( 10 years ago )

You can execute arbitrary GAP commands from Sage by using gap.eval(). (or libgap.eval(), which would interact with a different GAP process).

Dima gravatar imageDima ( 10 years ago )
0

answered 10 years ago

kcrisman gravatar image

Hmm, I bet that only Sage and Python know about the DATA variable in the notebook. A workaround is to simply print out the value of DATA in a Sage cell and then cut and paste that.

I tried it, but then ran into a problem of Gap in the notebook not taking very long lines!

Read("/home//notebook/sage_notebook.sagenb/home/kcrisman/5/data/test.txt");
RuntimeError: Gap produced error output
Syntax error: ; expected in ... test.txt line 2

That one I recall but I can't remember if there was a workaround.

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 10 years ago

Seen: 330 times

Last updated: Dec 01 '14