# What governs how Mathematica selects the appropriate format for an Import?

Under Mathematica 11, I have cobbled together an Import Converter that is able to handle simple cases of Apple Mail emlx files. I did this because, without the Importer, emlx files are imported either as text or as HTML. Further, attempting to import by passing "EML" as the format, fails completely.

After placing Import.m and Converter.m in ~/Library/Mathematica/SystemFiles/Formats/EMLX, $InputFormats does include 'emlx'. EDIT: I have since determined that the minimum for a format to be listed in the results of$ImportFormats is a zero length Import.m file located within a directory matching the file extension within the SystemFiles/Formats directory. Which calls into question, IMO, the accuracy of the documentation covering RegisterImport.

Unfortunately, emlx files still import as either HTML or Text. Ideally, I would want FileFormat["foo.emlx"] to return "EMLX" as its result. Currently, it returns HTML, TSV, CSV, or Text.

I have done the simple registration mechanism, also I tried to emulate that of the EML, and other example formats, yet still the Import framework is failing to automatically load the correct Converter. This leads me to believe that there is more that I have somehow missed to the registration process than placing Import.m, Converter.m, into a Format Directory and calling the registration mechanism.

The simplest registration I have done is :

ImportExportRegisterImport[
"EMLX",
EMLXEMLXImportExport
];


Again, it works when explicitly referenced. Yet it doesn't seem to autoload for some reason.

Interestingly, Wolfram Desktop does not list the EMLX format at all. Because of this, I'm inclined to believe that Mathematica and Wolfram Desktop files belong under ~/Library/Application Support rather than at the top level of any domain Library folder. Simply put, that would make it clear that these are specific to the installed App rather than applying to Wolfram products as a whole.

• Here is an example of an attempt to overwrite the Import for a specific file ending: Registering/detecting an importer by file name extension, try that approach and see if it works for you. – C. E. Sep 2 '16 at 7:23
• After trying all sorts of crazy things, I believe that Mathematica is using the same magic file as the OS to determine what import format to use. This would be fine if it were not for the fact that the most obvious method for correcting this by listing the format in ~/Library/Mathematica/SystemFiles/Formats/ExtensionMappings.m does not appear to work. – LibertyTrooper Sep 2 '16 at 7:28
• C.E. , I did try your method. I'm fairly new to Mathematica code having used it only for 'playing' in the past. So, I'll need to study a bit to understand it properly. Though, making the obvious changes to the format literal did not yield any changes in behavior. – LibertyTrooper Sep 2 '16 at 7:51
• I have had trouble overwriting Import myself, so I wasn't sure that it was going to work. Another example of this type of overwrite is the BVH Importer. You can scroll to the end of that answer to view the package, then scroll to the end of the package to see the way Import is overwritten. Hopefully someone can explain why it might not work. (It has to do with the precedence of the various DownValues of Import, but it's unclear why those rules don't take precedence because they are very specific.) – C. E. Sep 2 '16 at 8:30
• I did review the BVH importer. I shall do so again. Unfortunately, I'm beginning to think that I'll spend more time working around limitations than actually accomplishing that which I wish. I could say that I also wish that the enormous breadth of Mathematica documentation had a much more depth. I am hopeful that as other people come online today that someone will, pardon the obvious pun, have the magic solution. – LibertyTrooper Sep 2 '16 at 17:59