Automatic Load and Rename Waves

Dear Forum,

I will start working with some TXT files that I will import and extract the relevant waves.
Each TXT file has 3 sections corresponding to 3 different stages of a measurement, and for each section 11 properties (the actual waves) are reported - the same properties in all 3 different stages.

My question is on naming the extracted waves.

Each extracted wave should be named so that it contains a prefix indicating the "stage", a sufix indicating the property and the file name shown in the middle:

Stage01_FileName_Property01
Stage01_FileName_Property02
...
Stage03_Filename_Property01
Stage03_Filename_Property02
...
Stage03_Filename_Property11

I could do this by declaring all 33 waves, and going to each one of them and renaming them. But I would rather have some flexibility, since I will occasionally work with files that have only 2 sections, rather than 3.

Can I use LoadWave in such a dynamic way - i.e., so that it incorporates the file name in the in the wave name while loading (plus the prefixes and sufixes) - or, do I have to extract them all (e.g. LoadWave /A) and then make a for loop to rename each single wave?

Let me know how you would go about it.

Many thanks!!
You may be able to achieve what you want by using the LoadWave /B flag. This flag allows you to specify the wave name to use for each column as part of the LoadWave command.

This example shows how to use the /B flag to name multiple waves:
http://www.igorexchange.com/node/6409
Also see the LoadWave documentation for /B.

This example shows how to use the file name as part of the wave name. It is written for loading a 2D wave but the approach also applies in the 1D case:
http://www.igorexchange.com/node/5843

If this does not solve the problem then it would be helpful for you to attach a sample data file so I can get a better idea of what you are dealing with.
Thank you for answering Hrodstein.

The way I see it /B flag can be useful if all I am interested is in naming each wave with the same name across different files (which would not work, anyhow!). But i have a set of 11 properties which are measured at different stages during measurement, and they are grouped into segments in the txt file - and i have multiple txt files to process. So, I should name the waves in such a way that they contain, not only an indication of the property, but also the measurement file, and the stage at which the measurement took place.

I attach a typical example file. Each Stage/segment of the experiment is initiated by a long comment header marked with "#". Each stage can be uniquely identified by the comment line with a "segmentIndex" nr (0-3 in this file). Each segment contain 11 columns. Each set of columns contains values about the same property in all different segments

So, from such a file, I would like to extract the waves and named them such that all these different pieces of info are associated with each wave, for example: stage01_fileName_property01.

I don't see how the /B flag can help if I need to incorporate the fileName in the name of each wave I extract, together with the appropriate prefix and sufix... hope I was clear...
test_Curve01.txt (5.27 MB)
I have written a file loader for your file and posted it at http://www.igorexchange.com/node/7322

I did it differently than you requested, using data folders instead of your name convention. Read the comments at the top of the link for details. This organization has some advantages as explained in the Igor help. Execute this for details:
DisplayHelpTopic "Data Folders"


If you are an Igor programmer, you can probably modify what I have written to eliminate the data folders and specify the wave names as you wish. If you are not able to do this and would like me to take a crack at it, let me know.

Igor wave names are limited to 31 bytes so your naming scheme must satisfy that requirement. With your scheme, this will be a problem for long file names or long property names. You will need to rewrite the GetJPKSegmentColumnInfoStr function to satisfy the 31-byte limit.
Thank you so much Hrodstein!! I am amazed (so quickly, complete and on the bullseye!!)
Naming Data folders is indeed the best approach as I would have otherwise fairly long names in the files.
Thanks for the code and the tips! Really very much appreciated.

Cheers!!