0
$\begingroup$

I saved a table by exporting it to .mx file. Now, when I import it back, it gives me the desired output.

So, to work with elements of the table, I first define the imported table as (res2 = Import["file.mx"]), and res2 [[a,b,c,d]] returns the correct output from the table in correct sequence.

However, when I try to do any kind of simple algebra with it, It simply fails, even forget all the evaluations, I did before.

For example, when I try evaluating res2[[1,2,3,4]]+res2[[1,2,4,3]], Mathematica is unable to evaluate and even forget all the previous evaluations. What to do? I want to work with elements in the table of my file.mx. Otherwise what is the point of saving such huge collection of data?

Is there any alternative way, please tell me. It takes days to create the table. Now, I have the table saved in .mx file, but I am unable to do any algebra with elements. How to define a variable for the elements and work with it?

$\endgroup$
1
  • 3
    $\begingroup$ It is quite unclear to me how the data looks. Sounds as if it were symbolic... In order to narrow down what goes wrong: Have you tried to do the export and import with a somewhat smaller dataset? It would be great if you could provide a minimal example. $\endgroup$ Aug 26, 2019 at 11:55

1 Answer 1

0
$\begingroup$

Use Get:

Get["file-name.mx"];

If the table was called res2 When it was saved, then you should now have a symbol by the same name. You can now do

res2[[1, 2, 3, 4]]

as before.

$\endgroup$
6
  • $\begingroup$ I saved it using ( Export["file-name.mx",res2]; ), Get is also not working, It doesn't even know what is res2. $\endgroup$
    – Tripsy
    Aug 26, 2019 at 4:21
  • $\begingroup$ Save it using DumpSave. $\endgroup$ Aug 26, 2019 at 4:24
  • $\begingroup$ I have to run it again I guess for that. Can I import, define and dump-save again? i.e. ( res2 = Import ["file-name.mx"]) and then dumpsave res2? as that command is at least giving me correct values when I evaluate let's say res2 [[1,2,3,4]]. It just doesn't allow doing any algebra on it. $\endgroup$
    – Tripsy
    Aug 26, 2019 at 4:30
  • $\begingroup$ Unfortunately, I don't think there is a way to do that. MX is a binary format, and DumpSave is built to handle it correctly. $\endgroup$ Aug 26, 2019 at 4:42
  • $\begingroup$ I ll have to run it again, there is one very good method of writing and reading the table element wise, I will use that from next time..I just followed this advice before mathematica.stackexchange.com/a/51460/67076 but apparently it doesn't work properly, that answer is incomplete.. $\endgroup$
    – Tripsy
    Aug 26, 2019 at 4:48

Your Answer

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

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