Notebooks – How do I export a cell in the News Console to PDF?

Using V12 on Windows.

That's the problem. I'm calling an external function (Rubi in this case, but it could be anything) that prints a cell (image) to the console at the end. I just want to capture this cell and export it to a PDF file.

Even if I redirect the output to the current notebook, I can not use the command Export("image.pdf", NotebookRead(PreviousCell())); to do what I want, because the code calling the external function loops.

Is there a way to do the same thing Export("image.pdf", NotebookRead(PreviousCell())); but use the message console as a notebook instead of the current notebook?

To make it clearer, here is an MWE.

CurrentValue($FrontEnd, {"PrintAction"}) = {"PrintToConsole"};

(*a function which prints an image to console*)
externalFunction(max_) := Print(Plot(Sin(x), {x, -max, max}));

(*run a loop calling the function, and export its output*)

 (*need something like this*)
 (*Export("t.pdf",MessagesNotebookRead(PreviousCell())); ??*) 
 {n, 1, 5}

Enter image description here

Forwarding the print to the current notebook does not work

CurrentValue($FrontEnd, {"PrintAction"}) = {"PrintToNotebook"};
externalFunction(max_) := Print(Plot(Sin(x), {x, -max, max}));
 Export("t.pdf", NotebookRead(PreviousCell()));
 {n, 1, 5}

Since PreviousCell() In the above is not what I want, it will read the cell before the actual loop itself.

That too is not possible

CurrentValue($FrontEnd, {"PrintAction"}) = {"PrintToNotebook"};
externalFunction(max_) := Print(Plot(Sin(x), {x, -max, max}));
 Export("t.pdf", externalFunction(n))
 {n, 1, 5}

I could not instruct Mathematica to use the Message Console notebook as a notebook for the message console PreviousCell()

How best to export a cell in the message console to a PDF file? It will be the last cell every time, as in the example above. This happens in a loop. Each iteration generates a Rubi cell in the message console and I need to capture that cell as an image.


If anyone wants to try this with the actual Rubi issue, here is a MWE

<< Rubi`
CurrentValue($FrontEnd, {"PrintAction"}) = {"PrintToConsole"};
Do (
 Steps(Int(x Sin(x), x));
 (*save output in console to image, how?*)
 Steps(Int(x Cos(x), x))
 (*save output in console to image, how?*)
 {n, 2}

Enter image description here

Export – Converts any number to a displayed file name

I have defined a custom function that I find very convenient

fileName(base_, n_, r_) :=
   StringReplace(ToString(Round(n, r)), {"." -> "p", "-" -> "m"}),

It replaces the decimal point with the letter "p" (for "point"). It replaces the minus sign with "m". And you can cut off the number r for rounding off. Here are some examples

fileName("fig", #, 0.01) & /@ {0.23, -5.2, 10, 0.00001}
(* {"fig_0p23.pdf", "fig_m5p2.pdf", "fig_10p.pdf", "fig_0p.pdf"} *)

fileName("fig", #, 1) & /@ {-2, -1, 0, 1, 2}
(* {"fig_m2.pdf", "fig_m1.pdf", "fig_0.pdf", "fig_1.pdf", "fig_2.pdf"} *)

It's not perfect, but I like it a lot.

Interaction Design – Export assets from iOS and Android

I design both iOS and Android apps and use a tool-sharing tool, Sympli, that resembles a Zeplin-like tool. I need to know in which format I should download assets so that they can be used for both iOS and Android.
The main issue I'm trying to figure out is whether we can use the same iOS canvas dimensions (375 widths, 1x) to generate consumables for iOS and Android, and whether they match the design specifications.

Copy or export shared Google Calendar

I'd like to copy or export a shared Google Calendar listed under Other calendars.

I have found instructions on how to use the public address in iCal format. For the calendar that I want to copy or export, I do not have this information. Under "Integrate" there is only one "Calendar ID" and one "Public URL to this calendar".

When I open the public URL in a new browser, I can not find an option to save to .ics. I can only find options to save as a web archive.

How do I copy, save or export it in a format that can be imported into the Google Calendar or any calendar program?

oracle – export SCHEMAS and TABLES at the same time

My job is export schemas sch1, sch2

In addition, the tablespaces ts88, ts89 must be exported from schema sch3

How can I do it as an operation?
Because when I do different operations:

SCHEMAS=sch1, sch2


TABLES=sch3.ts88, sch3.ts89

it works well.

But if I try something like this:

SCHEMAS=sch1, sch2
TABLES=sch3.ts88, sch3.ts89

I have UDE-00010: requested several job modes, scheme and tables.

As I understand it, it is not possible to export with schemas and tables in this way.

Can I do it with INCLUDE or otherwise?
Or does it have to be 2 different operations?

Export – Exporting a grid as a PDF resizes the graphic. How to fix it?

I'm trying to export some numbers and charts for a publication, and I've decided to export the numbers in the size they need without rescaling them. This would ensure that fonts and line widths between the figures are consistent.

I also want to export the numbers as a PDF, as this is a vectorized format.

However, I came across a problem. Some of my properties are wrapped in a grid. I've found that when rendered as PDF, these graphs are smaller than an equivalent without the raster. This problem does not occur when I use the PNG format. The Grid and No-Grid charts are the same in PNG, but different in PDF. I notice that using ImageSizeMultipliers (as described here) has no effect.

The following code shows my problem with a minimal working example:

square1 = Graphics(Rectangle(), ImageSize -> 200)
square2 = Grid({{square1}})
Export("square1.pdf", square1);
Export("square2.pdf", square2);
Export("square1.png", square1);
Export("square2.png", square2);

Four squares, the output of the above code. The raster PDF square is smaller than the others.

(The four exported figures, rendered on the same page and labeled.)

Since the rescaling depends on the export format, this means that the export format, not the grid or graphics, is specifically incorrect.

Can I export the grid as a PDF without adjusting the scale of the other graphics?

If relevant, I use Mathematica version on Windows 10.

Machine Learning – How do I apply a classification model to predict test sets and export results as CSV in Python?

I have created an SVM model that has high accuracy for both classes (y = 0 and y = 1). The name of my SVM model is (grid_predictions). I want to apply this model (grid_predictions) to my test set data (the data that the predictions need). I have imported the test set and standardized the features and so the standardized data is now under (test_feat).

Now I want to use the grid_predictions model and apply it to my test set (to get the predicted y = 0/1 result) and export that prediction as CSV. I searched the internet for a tutorial on this topic but could not find a tutorial. Most tutorials focus on creating models, but rarely apply the model to a CSV test set and export the results.

Since I am new to Python, it would be nice if you helped me with code examples and referred me to relevant resources.

from sklearn.svm import SVC
svm_model= SVC() (X_train, y_train)
svm_pred= svm_model.predict (X_test)

print (confusion_matrix (y_test, svm_pred))
print ('/n')
print (classification_report(y_test,svm_pred))

from sklearn.model_selection import GridSearchCV

param_grid = { 'C':(0.1, 1, 10, 100),'gamma': (0.1, 1, 10, 100, 1000)}
grid = GridSearchCV (SVC(), param_grid, verbose=3) (X_train,y_train)
grid_predictions = grid.predict (X_test)

print (classification_report (y_test, grid_predictions))

Test_set is imported

test_set= pd.read_csv (r'C:Users....Desktopmltest.csv', index_col=0)

Scale test_set features

scale_test = StandardScaler() (test_set.drop('retained', axis=1))
test_features=scale_test.transform (test_set.drop ('retained', axis=1))
test_feat =pd.DataFrame(test_features,columns=test_set.columns(:-1))

Now I want to apply the SVM model to use the scaled functions to predict the & # 39; Create column.

How do I export all graphics from a notebook?

I have a notebook with about 50 expressions like this:

data = Table(i, {i, 10});
ListPlot(data (*, some Plot options *))

output cell

I want to export all of these drawings to separate image files in the destination directory.

Monkey work

You can right click on -> "Save graphic as …". But this works tedious, boring and impractical.

Export last issue

Another idea I had was copying and pasting a simple command that exported the last issue after there were ~ 50 diagrams:

data = Table(i, {i, 10});
Export(NotebookDirectory() <> "\pics\" <> ToString(++globalPicCounter) <> ".png" 
 , %, "PNG") (* this line is manually pasted after every Plot in the notebook *)

Do not forget to bet globalPicCounter to 0 before you start exporting everything.

This also works and has dissatisfied me too. It does not differ much from Mokey work, it breaks if Plot was not the last issue, and if you want to reset the notebook to its original state after work is done, you need to do more monkey work.

This idea can be improved: I can search and replace all pure function diagrams that do the same:

Export(NotebookDirectory() <> "\pics\" <> 
    ToString(++globalPicCounter) <> ".png", #, "PNG") &@ListPlot...

Plot() packaging

The next idea that came to my mind was to implement Villegas-Gayley wrappers for Plot:

globalGraphicsCounter = 0;

 ListPlot(args___) /; Not@TrueQ($inMsg) :=  
   Block({$inMsg = True, result},
    result = ListPlot(args);
     NotebookDirectory() <> "\pics\" <> 
       ToString(++globalGraphicsCounter) <> ".png", result);


To my surprise, that did not work. ListPlot is evaluated as usual without a plot being exported. Some put Print(...)is in the packaging of ListPlot indicates that the new definition of ListPlot is not used. I tried to do the same thing Message(...) Villegas-Gayley wrapper in the initial setting to replicate and it works as expected.

So, although this would be a really nice solution, I did not manage to get it up and running.

Author Tools package

In search of another way to export land, I came across it Author Tools Package. There is a Export Cells Palette that "allows extracting content of a particular type from a particular notebook or project and storing the content in a desired format". There is an option to export all graphic cells, but when I try, the following error message appears:

AuthorTools ExportCells error message

I did not succeed in trying to figure out what it is all about.

I also tried to export lots of land AuthorTools`ExportNotebook():

In(90):= ExportNotebook(EvaluationNotebook(), "Graphics", "PNG")

Out(90)= {}

and did not have much success. It turned out that all graphic objects from the notebook returned an empty list. Where are all the plots? I found them when I tried to export them all Input Cell Groups With _AuthorTools_`ExportCells Palette. All diagrams are located in the output cells that are in the input cell groups.

Low-Level Notebook Programming

I think there is also an option to work with low-level laptops and cell expressions to create a simple parser for this task. But I have very vague understanding of how to do it.

This method may have an additional benefit: you do not need to re-evaluate your notebook.

For some further considerations, I understand that this problem has two slightly different variations depending on the constraints imposed:

  • If evaluations in the notebook are not time-consuming, you can use methods that re-evaluate the notebook or some cells in it.

  • If the evaluations in the notebook are long, you should use a method that does not require the notebook to be reassessed.

And although my notebook is "light" in this case, I find it interesting and useful to make a distinction if the proposed methods are subject to additional constraints (there may be others, but an evaluation time that I did not think of) ,

I want to put variables previously defined in PHP into an array and then export them to json

$toJson = array();
$arr = array_push($toJson, array(
    'numero_casas' => $n,
    'token' => $myToken,
    'cifrado' => $criptografada,
    'decifrado' => $desCriptografada,
    'resumo_criptografico' => $rc

echo $toJson;

$exitJson = json_encode($toJson);

echo $exitJson;

$file = fopen("answer.json","w+");

fwrite($file, $exitJson);