6654
How to explore and use the content of a data .sav file in IDL?
Before restoring a .sav file which is only including variables you may want to explore its content first. This is possible using the IDL_Savefile object class
; select your data .sav file
f=dialog_pickfile()
; create the IDL_Savefile object from this .sav file and query its content
sObj=IDL_Savefile(f)
content=sObj.Contents()
; you can then access the number of variables included in this .sav file
; as well as the variable names
print,content.N_VAR
foreach Name, sObj.Names() do print,Name,sObj.size(Name)
; you can then decide to restore only specific variables based on their names
data=sObj.Names()
sObj.restore,(data[0])
Another useful option is to convert specific variable names into a variable identifier using SCOPE_VARFETCH, so you can then manipulate this variable in your IDL code afterwards
b=SCOPE_VARFETCH(data[0])
help,b
------------------------------------------------
Created by BC on 1/19/21
Reviewed by BC(US) on 1/21/2021