6

For my Skeptics working group I wrote a program in Mathematica to test a dowser's ability to assess the status of persons shown to them by means of photographs. For a null measurement I distributed this document to my group's members in CDF form (the new v8 Computable Document Format, meant to be run with the CDF-player). On my computer (using mma) it all works fine, but the others can't export the data (the program does an export to an Excel file). On reading the fine print I see that the player doesn't support Export. So my question is:

Is there any way to get data out of CDF-player?

Verbeia
  • 4,400
  • 2
  • 23
  • 44
Sjoerd C. de Vries
  • 16,122
  • 3
  • 42
  • 94
  • 4
    I suspect that if there is, and someone posts it here, it won't be there in the next build. – Mr.Wizard Apr 08 '11 at 09:07
  • 2
    @Mr.Wizard 8^( We are doing this is for the good of humanity. Let my data go! – Sjoerd C. de Vries Apr 08 '11 at 09:18
  • 1
    John Fultz (Wolfram Research) wrote in his [recent post](http://groups.google.com/group/comp.soft-sys.math.mathematica/msg/854d998efd65cc8d) in the official newsgroup: "It is possible, incidentally, to create CDF files with the capacity to, while running in Player, create content using Export[], saving, etc. But that functionality can't be unlocked directly from within Mathematica, and more will be said about that later, as well." – Alexey Popkov Jul 08 '11 at 14:45

3 Answers3

7

For understandable reasons, the math/CDF player is severely limited in both input and output.

However, Print works, so you could print in TableForm - which produces a TSV - then copy/paste it into Gnumeric ('cause why would you use Excel?!).

I just tested this in both Gnumeric and OpenOffice and it worked fine.

Put the following code into a CDF document to test.

Button["Press me!", Print[TableForm[RandomReal[{0, 1}, {10, 10}]]]]

Note that you can't edit the Input, but you can press the button and copy the output. Skeptics groups are normally fairly technically competent people, this should probably be a workable solution...

enter image description here

Simon
  • 14,631
  • 4
  • 41
  • 101
  • @Simon +1 I currently don't have the CDF-player installed. Have you tried this in MMA or in the player? – Sjoerd C. de Vries Apr 08 '11 at 14:05
  • I put the code in a Mma8 notebook, saved as a .cdf and loaded it into the CDF Player. The print button worked fine. (Note the CDF Player bar at the top of the screenshot) – Simon Apr 08 '11 at 14:07
  • btw: [A 2003 report on Gnumeric vs Excel](http://www.csdassn.org/reportdetail.cfm?ID=508). The end of the abstract says "Persons who desire to use a spreadsheet package to perform statistical analyses are advised to use Gnumeric rather than Excel." The site also has a review of Mma7. – Simon Apr 08 '11 at 14:13
  • -1 for "Skeptics groups are normally fairly technically competent people". There are no references to prove that. :) – Dr. belisarius Apr 08 '11 at 18:02
  • 2
    @belisarius LOL. See the skeptics stackexchange and try posting there without references. – Sjoerd C. de Vries Apr 08 '11 at 19:35
  • 2
    @belisarius: The evidence is clear. @Sjoerd Is a member of his skeptics group and posted the question. Generalize his level of expertise to the whole group and QED. – Simon Apr 08 '11 at 21:37
  • @Simon Your reasoning path sounds very familiar to me. I surely heard of it before. – Dr. belisarius Apr 09 '11 at 05:53
6

I thought that I could encode my data in a picture which I then would have the group members copy from the CDF document and email to me. It looked something like this:

enter image description here

The top row to define the data slots and the bottom row contains the data encoded as color. However, I found that Outlook compresses pictures placed in an email body, so you get slightly blurred pictures, and hence corrupted data. The next step was to use a more robust code like the QR barcode. Luckily, since last week Wolfram|Alpha is able to generate QR barcodes, like so:

WolframAlpha[
 "QRcode:\"" <> ToString[N[Pi, 100]] <> "\"", {{"QRCodeBarcode", 1}, 
  "Content"}]

enter image description here

I have now downloaded and installed the CDF-player myself and it seemed to work in a CDF document as well, though I had to generate the QR code a second time, before it handled the internet connection correctly. Don't know whether this is a spurious result.

Sjoerd C. de Vries
  • 16,122
  • 3
  • 42
  • 94
  • Does the call to Alpha work in a machine without Mma installed? Seems strange, since it needs a Mma license ... – Dr. belisarius Apr 08 '11 at 17:57
  • @belisarius I'm afraid I don't have a machine without MMA ;-) Do you have one? – Sjoerd C. de Vries Apr 08 '11 at 19:18
  • @Sjoerd - Nice find on the QR codes! I was actually going to request this feature. – telefunkenvf14 Aug 05 '11 at 17:25
  • @telefunken There are more parameters you could set in this command then shown here. You can include the error correction level as well: `WolframAlpha["QR code \"test\"", {{"QRCodeBarcode", 1}, "Content"}, PodStates -> {"QRCodeBarcode__Level H error correction"}]`. There are are L, M, Q and H levels to be chosen here. – Sjoerd C. de Vries Aug 05 '11 at 20:04
  • @Sjoerd Awesome info. Can't believe I haven't come across this capability before. Question: Have you ever tried feeding a QR image file back to W|A? (i.e., will W|A decode QR codes too?) – telefunkenvf14 Aug 06 '11 at 01:59
  • @telefunkenvf14 I don't think WA can do that. I used an iPhone app. There are several online QR code readers that you could try too. – Sjoerd C. de Vries Aug 06 '11 at 07:49
2

For version 7, there was Mathematica Player and Mathematica Player Pro. The Player was free, but had not Export capabilities. Player Pro required a fee, but could do export. According to http://www.wolfram.com/cdf-player/ the CDF player is descendant from Player part, and I am unaware of CDF equivalent to Player Pro yet, it might have not been released yet. Did you try writing to tech-support ?

Sasha
  • 5,935
  • 1
  • 25
  • 33
  • +1 but the only problem is that I can't see people in the Skeptics group paying a PlayerPro-type fee for something small like this... – Simon Apr 08 '11 at 14:01
  • @Simon I agree. I programmed it in MMA because I already had the data there and could do it quick and dirty. If it's gonna cost money, we'd better be looking for something else. – Sjoerd C. de Vries Apr 08 '11 at 14:07
  • @Sjoerd: I understand completely. If you don't need a graphical interface, maybe you could try the new C-code generation in Mma8... Or maybe put the whole thing onto a public [Sage notebook](http://demo.sagenb.org/). (It's nice not having to follow the strict censoring rules of [mathgroup](http://forums.wolfram.com/mathgroup/)...) – Simon Apr 08 '11 at 14:19
  • @Simon As I understood it this code generating stuff doesn't include graphics, user interface elements and `Dynamic` stuff, or does it? – Sjoerd C. de Vries Apr 08 '11 at 14:49
  • 1
    @Sjoerd Not, the code generation only includes mathematical functions and programming constructs. It is easy to find out is a function is supported in Compile. You should use CompilePrint from CompiledFunctionToos` package in v8. The package is included already. In[3]:= Needs["CompiledFunctionTools`"] In[9]:= StringSplit[ Compile[{{mat, _Real, 2}}, Inverse[mat]] // CompilePrint, EndOfLine][[-3 ;; -1]] Out[9]= {" 1 T(R2)1 = MainEvaluate[ Hold[Inverse][ T(R2)0]]", " 2 Return", " "} The MainEvaluate in the output indicates that Compile will be calling back into Mathematica – Sasha Apr 08 '11 at 15:25