2
$\begingroup$

My question is about creating a Manipulate based on a external dataset (in my private Cloud) and publish it in the Public Cloud.

data = Import["filename.TXT","Table", {"FieldSeparators" -> "|", "CharacterEncoding" -> "ASCII","HeaderLines" -> 1, "EmptyField" -> "","RepeatedSeparators" -> False,"DateStringFormat" -> {"Year", "-", "Month", "-", "Day"}}]

The output is:

{{0,1,0,0,0,5},{1,1,1,1,1,297},{1,2,0,1,1,5},.......{1,3,1,1,1,1}}

The script for creating the manipulate is:

    man=Manipulate[
ListLinePlot[{Select[data[[All, {1, 2, 3}]], #[[1]] == Round[bonbedrag] &][[All, {2, 3}]],
Select[data[[All, {1, 2, 4}]], #[[1]] == Round[bonbedrag] &][[All, {2, 3}]],
Select[data[[All, {1, 2, 5}]], #[[1]] == Round[bonbedrag] &][[All, {2, 3}]]}, Filling -> {1 -> {2}},
FillingStyle ->  LightBrown,
PlotStyle -> {{Red, , Thick}, {Blue, Thick}, {Green, Dashed, Thick}},
PlotLegends ->
Placed[{"ondergrens", "bovengrens", "gemiddeld"}, Below],
InterpolationOrder -> 2,
AxesLabel -> {Style["aantal artikelen gekocht", Bold, Red],
Style["prijs duurste artikel", Bold, Blue]}, ImageSize -> Large,
PlotLabel ->
Style[Framed[StringForm["Bonbedrag = Euro " <> ToString[Round[bonbedrag]]]]],
GridLines -> Automatic,
GridLinesStyle -> Directive[Orange, Dashed],
PlotRange -> {{0, 20}, {0, 200}}, AxesOrigin -> {0, 0}
],
{bonbedrag, 1, 200, 0.01},
Bookmarks -> {"start" :> (bonbedrag = 0),
"end" :> (bonbedrag = 200), "back" :> (bonbedrag = 0)},
SaveDefinitions -> True]

Then I export this manipulate using CloutPut with the permissions Public

CloudPut[man, Permissions->"Public"]

You can see the result at:

CloudObject[https://www.wolframcloud.com/objects/a2b420d3-9774-4ef8-b2f5-4a3214a6383e]

What you see is not the Manipulate but the original code. As far as I understand, the reason is the external dataset.

Anyone a suggestion how to solve this issue?

Thanks, Michiel

$\endgroup$
1
$\begingroup$

Using With and CloudDeploy (and an extra Column somehow) will do it:

man = With[{data = (* Import[ ... ] *)
      { {0, 1, 0, 0, 0, 5}, {1, 1, 1, 1, 1, 295}, {1, 2, 
       0, 1, 1, 5}}},

 Manipulate[
    Column[{"",
      ListLinePlot[{Select[
          data[[All, {1, 2, 3}]], #[[1]] == 
            Round[bonbedrag] &][[All, {2, 3}]], 
        Select[data[[All, {1, 2, 4}]], #[[1]] == 
            Round[bonbedrag] &][[All, {2, 3}]], 
        Select[data[[All, {1, 2, 5}]], #[[1]] == 
            Round[bonbedrag] &][[All, {2, 3}]]}, 
       Filling -> {1 -> {2}}, FillingStyle -> LightBrown, 
       PlotStyle -> {{Red, , Thick}, {Blue, Thick}, {Green, Dashed, 
          Thick}}, 
       PlotLegends -> 
        Placed[{"ondergrens", "bovengrens", "gemiddeld"}, Below], 
       InterpolationOrder -> 2, 
       AxesLabel -> {Style["aantal artikelen gekocht", Bold, Red], 
         Style["prijs duurste artikel", Bold, Blue]}, 
       ImageSize -> Large, 
       PlotLabel -> 
        Style[Framed[Row[{"Bonbedrag = Euro ", Round[bonbedrag]}]]], 
       GridLines -> Automatic, 
       GridLinesStyle -> Directive[Orange, Dashed], 
       PlotRange -> {{0, 20}, {0, 200}}, 
       AxesOrigin -> {0, 0}]}], {bonbedrag, 1, 200, 0.01}, 
    Bookmarks -> {"start" :> (bonbedrag = 0), 
      "end" :> (bonbedrag = 200), "back" :> (bonbedrag = 0)}, 
    SaveDefinitions -> True]];
CloudDeploy[man, Permissions -> "Public"]
$\endgroup$
  • $\begingroup$ Hi Rolf, Can you more explicit about the part "data = (* Import[ ... ] *)" When I tried man = With[{data = Import["filename.TXT","Table", {"FieldSeparators" -> "|", "CharacterEncoding" -> "ASCII","HeaderLines" -> 1, "EmptyField" -> "","RepeatedSeparators" -> False,"DateStringFormat" -> {"Year", "-", "Month", "-", "Day"}}]}], it failed. $\endgroup$ – Michiel van Mens Jun 15 '15 at 12:06
  • $\begingroup$ @MichielvanMens it should just work. Maybe you have to give a full path name ? $\endgroup$ – Rolf Mertig Jun 15 '15 at 22:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.