How to avoid LoadWave/W/A creating identical wavenames from a single file "two or more names are identical"

Dear IgorExchange,

I am attempting to use LoadWave within a larger function to import an entire folder of text files, which usually works fine (and the in-built examples to this end are very good). I use LoadWave with the /W and /A flags to read and use the column headers as wave names. The data file is a tab separated ASCII, and I've attached an example.

If you run LoadWave as below on the attached file, you will reproduce the error (I'm using Igor 8).

LoadWave/D/J/W/A ""

From my understanding, the /W flag seems to read the column headers, and then run something similar to CleanupName on the potential wave names. I think this leads to some of the column headers being identical, and thus stops LoadWave with the "two or more names are identical" error. Is that correct?

Any ideas on how to manage this error?

Ideally I'd not define the wavenames in advance (e.g., with the /B flag), since the script loads files with different data columns.

Many thanks in advance and any advice would be much appreciated

Shannon

Example Text to Load (27.3 KB)

You might consider one of the following:

1. allow Igor to assign default wavenames (loadwave /A);

extract the column headers from the file;

rename the loaded waves as you need (S_waveNames gives you the loaded waves).

or

2. extract the column headers from the file;

figure out names for waves and construct the /B flag for loadwave based on the column headers.

The file has colums labeled "<Ewe>/V" and "|Ewe|/V". As you determined, after being cleaned up, these evaluate to the same thing, namely "Ewe__V". Ideally Igor should handle this, but it is a very rare thing.

In addition, the file has two columns named identically: "<I>/mA".

Either of Tony's suggests would work, but they are non-trivial to implement. Your best bet might be to just fix it manually when the problem arises.

If you want to try to fix it programmatically, here is a snippet that might serve as a starting point.

 

Those are good ideas. I'll try programmatically solving it as suggested, probably with Tony's first suggestion as it should be very robust.

Thanks again for the advice, much appreciated!

Unless you need to work with a large number of files it may be easier to simply use Igor's built-in dialog for loading waves under Data>Load Waves>Load general text. The dialog will suggest wavenames and give you a chance to edit any name clashes. If you use Loadwave /G in a loop it takes only a moment to change the names that are flagged. You could create a new data folder for each set of waves. Writing custom file loaders is useful when you have some associated processing that you want to automate or header information that you want to preserve, but your example file looks quite straightforward, aside from the wave naming problem.

Indeed the example text file I uploaded looks straightforward, but I trimmed it quite a bit by cutting out the headerlines. I have a custom loader for the reasons you described. It reads the number of headerlines out of the file (since the number of headerlines changes but is specified in the text at a fixed position), creates a directory for each file, extracts some meta-data from headerlines, loads each column as a wave (though there are differing column numbers and names depending on the measurement type), and also does some processing. I've wanted to keep the custom loader working for all files from that specific instrument. Your suggestion to readout the headerlines and process them manually indeed wasn't trivial, but I've got it working, cleaned them up and used the /B flag. This works well (so far) and was a great suggestion

Forum

Support

Gallery

Igor Pro 9

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More