Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
Register an extension or MIME type for automatic detection in Import, Export, and FileFormat
ResourceFunction["RegisterFormat"]["fmt", <|"Extensions"→ext|>] registers the extension ext to format "fmt". | |
ResourceFunction["RegisterFormat"]["fmt", <|"MIMETypes"→type|>] registers the mime type to format "fmt". | |
ResourceFunction["RegisterFormat"]["fmt", <|"Extensions"→ext,"MIMETypes"→mime|>] registers the extension ext and the mime type format "fmt". |
Register "myjson" to the "JSON" format:
In[1]:= | ![]() |
Out[1]= | ![]() |
Now "myjson" will additionally be recognized as an extension for "JSON":
In[2]:= | ![]() |
Out[3]= | ![]() |
Register format "myFmt":
In[4]:= | ![]() |
Register an extension for "myFmt":
In[5]:= | ![]() |
Out[5]= | ![]() |
Import, Export, and FileFormat, now infer the extension from the file name:
In[6]:= | ![]() |
Out[6]= | ![]() |
In[7]:= | ![]() |
Out[7]= | ![]() |
In[8]:= | ![]() |
In[9]:= | ![]() |
Out[9]= | ![]() |
RegisterFormat can also be used to modify the MIME type or extension of an existing format. Create a test file with a custom extension "mycsv" to register to "CSV":
In[10]:= | ![]() |
The extension .csv should already be recognized:
In[11]:= | ![]() |
Out[11]= | ![]() |
By default, "mycsv" would be imported at "Text":
In[12]:= | ![]() |
Out[12]= | ![]() |
Register "mycsv" to the "CSV" format:
In[13]:= | ![]() |
Out[13]= | ![]() |
Now "mycsv" will additionally be recognized as an extension for "CSV":
In[14]:= | ![]() |
Out[14]= | ![]() |
The original extensions still work:
In[15]:= | ![]() |
Out[15]= | ![]() |
This work is licensed under a Creative Commons Attribution 4.0 International License