Wolfram Function Repository
Instant-use add-on functions for the Wolfram Language
Function Repository Resource:
A version of Import which uses a cache of the result unless the source file has changed
ResourceFunction["ImportOnce"][file,opts] imports data from file, caching the result unless the contents of file has changed. |
| "ComparisonMethod" | "LastModificationDate" | method for deciding whether the file has changed, requiring a new import and cache |
| "ForceImport" | False | override the cache, forcing the file to be re-imported. |
ImportOnce behaves the same as Import:
| In[1]:= |
| Out[1]= | ![]() |
But if you use it again on the same file, and the file has not changed, it is faster:
| In[2]:= |
| Out[2]= | ![]() |
Change the method for deciding if a file has changed:
| In[3]:= |
| Out[3]= | ![]() |
| In[4]:= |
| Out[4]= | ![]() |
If you have reason to believe that the file has changed in a way that is not detected by your choice of "ComparisonMethod", you can force a refresh with "ForceImport"→True:
| In[5]:= | ![]() |
| Out[5]= | ![]() |
ImportOnce can only pre-check file changes for local files. Importing over http or https will always import the file again:
| In[6]:= |
| Out[6]= |
| In[7]:= |
| Out[7]= |
Wolfram Language 11.3 (March 2018) or above
This work is licensed under a Creative Commons Attribution 4.0 International License