Accessing Loaded waves within a procedure
Dolbash
I've been working on some code that isn't too complicated and I've found a few posts about what i'm trying to do, but pretty much, I want to access various folders and load the delimited text files from within the folders, entire folders at a time. Here are the hangups that make it different:
-Each pice of data has 2 sets of delimeted text files associated with it. They are in the folder like this:
file1_ch1
file1_ch2
and it is easy enough to put the loop in my code to iterate by 2 each step to pull onnly every other set. However, in the files, I only want the second column of data which I have achived with the /L flag in loadwaves.
Herein lies the first issue. I really would like an option not to load the same waves if i add more files from the same folder, But as is, I keep getting duplicate waves if i use the same procedure multiple times on the same source folder. I've tried an if statement that compares the content of the waves using waveexists() funtion, but since I am only using the second column, i think it's sneaking by this if statement. This is the first issue that I am trying to resolve.
The second lies with the naming of the waves. because of the loadwave function, The waves go straight from my folder to the :root: folder , and are named wave# incremented by 1 according to the /a flag. I would like the ability to append the waves to a table as I load them into igor. but since I don't know the # that is getting assigned to them as they are loading into igor, I have been unable to do this. Also, since data is loaded in more than once, Assigning the waves a #= loop# won't work since it would get overwritten. Is there a way to extrapolate the name of the actual wave that is being automatically assigned as it gets loaded into igor, and store it as a string or as an actual wave in the program?
Thirdly, more simply, is there a way to sort waves by number of points?
lastly, here is my code attached as image. And if you choose, to help, please try to not be too complicated, I'd really liek to understand how things work so i can move on from here.
If you omit /O, LoadWave will autoname waves. You can then use the S_waveNames output variable from LoadWave to determine the names used.
That said, I prefer to use the /B flag which provides complete control of wave names. It also allows you to skip column. Here is an example: http://www.igorexchange.com/node/6409. See also the discussion of /B in the LoadWave help.
February 17, 2017 at 05:15 pm - Permalink
* Create a string of the list of file names loaded. Store that with the waves. At the next time that you read from that folder, compare the string list against the new list of file names. Remove the previously loaded files from the list and only load those remaining.
* Create a string that marks the "files last loaded" date + time. When you invoke the file loader, compare the modification or creation date of the files in the folder. Only load those files that are older than your "files last loaded" date + time.
I cannot comment which is better for your use case. The second approach has an advantage that it is independent of where the files are located on the hard drive. You only care that you load files that are OLDER than the existing, regardless of source. The first case has the advantage that it can load files independently of the date they were created. So, should you be collecting files from different instruments and happen to get certain ones at a later date that were however created earlier than your last file load, you can still load them as "new".
--
J. J. Weimer
Chemistry / Chemical & Materials Engineering, UAH
February 19, 2017 at 02:02 pm - Permalink