How to save table output in an exportable manner in Sage

Viewed 120

I am a sage novice trying to export a table output to some image format (so that it might be shared). I tried using the .save() function as so:

my_table1 = table(my inputs) result = my_table1.transpose() result.save('here')

My table outputs properly after I run the program (not featured), but for some reason I receive the following error when I try and save the table:

"Error! /home/sage/Documents/here.sobj is not UTF-8 encoded

Saving disabled.

See Console for more details."

Any help in exporting this table is greatly appreciated. Additionally, if you require any more information please do not hesitate to ask!

Background: I am working in Jupyter for Sage on a browser via localhost/8000; not sure if that matters. My OS is Windows 10 and I am using Sage version 7.6.

1 Answers

Would LaTeX output help? Using an example in the documentation for table?:

rows = [['a', 'b', 'c'], [100,2,3], [4,5,60]]
table(rows)._latex_()

'\\begin{tabular}{lll}\na & b & c \\\\\n$100$ & $2$ & $3$ \\\\\n$4$ & $5$ & $60$ \\\\\n\\end{tabular}'

You could try for the html but that would be harder, because it returns a HTMLFragment object, and you'd need the MathJax for it to look right.

str(table(rows)._html_())

'<div class="notruncate">\n<table  class="table_form">\n<tbody>\n<tr class ="row-a">\n<td>a</td>\n<td>b</td>\n<td>c</td>\n</tr>\n<tr class ="row-b">\n<td><script type="math/tex">100</script></td>\n<td><script type="math/tex">2</script></td>\n<td><script type="math/tex">3</script></td>\n</tr>\n<tr class ="row-a">\n<td><script type="math/tex">4</script></td>\n<td><script type="math/tex">5</script></td>\n<td><script type="math/tex">60</script></td>\n</tr>\n</tbody>\n</table>\n</div>'

In any case, the image wouldn't be savable as-is. Unless you took a screenshot!

Related