I have a array of Mathematica files which I am running one after another using NotebookOpen/SelectionMove/SelectionEvaluate functions successfully.

In this evaluation, the o/p of each file is a matrix, which is the input for next file. Say, the o/p X = {{1, 2}, {3, 4}} in file1, I want to be "Imported" to file2 as Y.

I tried Y = Import["Desktop/file1.nb", X] in file2, but it comes back with message $failed !!

Will appreciate any suggestion on this.

  • $\begingroup$ How are you exporting X? $\endgroup$ Nov 5, 2019 at 15:12
  • $\begingroup$ Export["Desktop/file2.nb", X] $\endgroup$
    – user49535
    Nov 5, 2019 at 15:28
  • $\begingroup$ Then why are you importing from file1.nb? What is X that is passed to Import? $\endgroup$ Nov 5, 2019 at 15:33
  • $\begingroup$ Both of them not working. Neither individually nor together. $\endgroup$
    – user49535
    Nov 5, 2019 at 15:48

1 Answer 1


Sorry, I have a hard time understanding your comments. This should help you with exporting and importing data between notebook files.

In file1.nb

x = {{1, 2}, {3, 4}};
Export["~/output.mx", x];

In file2.nb

y = Import["~/output.mx"]
(* {{1, 2}, {3, 4}} *)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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