Loading an entire directory
astrotool
Function CCNLoader()
// Loads one file at a time, edits time wave, adds them to the proper waves, then deletes them
do
LoadWave/J/D/A=wave/K=0/L={4,6,0,0,0}
if (V_flag == 0) // Break if user hit the cancel button.
break
endif
GetFileFolderInfo/Z S_path+S_fileName
if( V_Flag == 0 && V_isFile ) // file exists
wave wave0 // changes time data -> Time and Date data
wave0=X
wave0+=V_modificationDate
endif
Concatenate/NP {wave0}, TimeAll
Concatenate/NP {wave1}, CurrentSSAll
KillWaves wave0,wave1
if (wAVEExists (wave48)) //check command history to see if there were alarms
Killwaves wave48
print "ALARM!!!"
else
print "No Alarms"
endif
while(1)
End
// Loads one file at a time, edits time wave, adds them to the proper waves, then deletes them
do
LoadWave/J/D/A=wave/K=0/L={4,6,0,0,0}
if (V_flag == 0) // Break if user hit the cancel button.
break
endif
GetFileFolderInfo/Z S_path+S_fileName
if( V_Flag == 0 && V_isFile ) // file exists
wave wave0 // changes time data -> Time and Date data
wave0=X
wave0+=V_modificationDate
endif
Concatenate/NP {wave0}, TimeAll
Concatenate/NP {wave1}, CurrentSSAll
KillWaves wave0,wave1
if (wAVEExists (wave48)) //check command history to see if there were alarms
Killwaves wave48
print "ALARM!!!"
else
print "No Alarms"
endif
while(1)
End
Files are recorded like this every hour
CCN data YYMMDDhhmmss.csv
CCN data 080601125425.csv
CCN data 080601135426.csv
CCN data 080601145427.csv
I don't understand your question. But I think the answer to your question is no. As far as I know, there's not really a way in any programming environment to load an entire directory at once, because directories are a collection of files and therefore each file must be loaded individually.
Maybe I'm not understanding your question.
June 10, 2008 at 05:55 am - Permalink
Consider that you have two functions ...
string theFile
<load the file>
return (string list of waves loaded or "" if no waves loaded)
end
Function DoMyOperation(ListofWaves)
string ListofWaves
<do what you need to do on each wave(s) in the string list itsWaves>
return 0
end
You can do one of the following:
string theList
// theList = a string listing of the full path to all files in a certain directory
...
// LOOP ON (load + operate)
for (ic=0;ic<nt;ic+=1)
sprintf theFldr, "root:MyFolder%d", ic
NewDataFolder/O/S $theFldr
theFile = StringFromList(ic,theList)
itsWaves = LoadMyFile(theFile)
if (strlen(itsWaves)==0)
break
endif
DoMyOperation(itsWaves)
endfor
return 0
end
Function DoItAll_B(theList)
string theList
// theList = a string listing of the full path to all files in a certain directory
...
// LOOP ON (load)
for (ic=0;ic<nt;ic+=1)
sprintf theFldr, "root:MyFolder%d", ic
NewDataFolder/O/S $theFldr
theFile = StringFromList(ic,theList)
itsWaves = LoadMyFile(theFile)
if (strlen(itsWaves)==0)
break
endif
endfor
// LOOP ON (operate)
for (ic=0;ic<nt;ic+=1)
sprintf theFldr, "root:Myfolder%d", ic
SetDataFolder $theFldr
itsWaves = WaveList("*",";","")
DoMyOperation(itsWaves)
endfor
return 0
end
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
June 10, 2008 at 11:43 am - Permalink
Yes. Execute this to see the relevant help:
DisplayHelpTopic "Loading All of the Files in a Folder"
June 10, 2008 at 12:44 pm - Permalink