The documentation says
Import["file.mx"]
is equivalent toGet["file.mx"]
.
However, I have at least one instance where Get["file.mx"]
gives Null
, while Import["file.mx"]
gives some result (the intended result). I can literally start in a clean Kernel and do one or the other and it is perfectly clear that they are not equivalent. (I even renamed the file to be "file.mx" sort of as a joke, just to proof the documentation completely wrong.)
Now I know this is not the place to put a bug report, but does anyone understand what is going on? (As a side note, there isn't any way to attach a file to a question right?).
This seems to be pretty universal behavior actually. To test it use:
Export["file.mx", {a, b, c}]
and try for yourself. Also adding the format "Package"
or "MX"
to Get
does not affect the result (neither does adding "MX"
as the format when exporting).
In more practical terms. I need a function that reliably reads and evaluates data of this type (i.e. matrices or matrices with some function wrapper around them) whether they are stored in an .mx
file or in a .txt
file (it needs to be able to handle both). Import
does not work as this universal function as it will read in the .txt
file as a string. I think that ToExpression[Import[#]]&
might work universally but I still have to verify this.
MX
is a binary format whilePackage
is a textual format, they aren't equivalent. $\endgroup$