How to load wave from text file with two different delimiters

I'm new to Igor, and trying to load wave data from a file from a specific program (EPL Cochlear Function Test Suite); however, I am stuck and seeking advice. Below is a sample of how the wave files are formatted, where line 2, LEVELS, contains the name for each wave (20;25;30; etc), and line 4 begins the wave data. Using the loadwave function, 

loadwave /J/L={0, 4, 0, 0, 0}

I can import the correct waves--but I cannot figure out how to load the wave names as they use a different delimiter (semicolons vs tabs).

Ideally, I would like to be able to load the wave names, and also add text to the beginning of them. Does anyone have any advice?

I know that if I manually change the text in line two to something like, "LEVEL_20     LEVEL_25     " etc I can get the file to load, but I have too many files to do this type of manual labor. Thank you anyone that can help!

****DATA SAMPLE BELOW****

:CFTS Version: V2.36 (R2780)

:LEVELS:20;25;30;35;40;45;50;55;60;65;70;75;80;

:DATA  

0.012304      0.014133      0.003775     -0.005442      0.002555     -0.000217     -0.012315      0.021623     -0.031939     -0.039863     -0.009497     -0.040325     -0.004889  -0.001091      0.015399      0.000640     -0.018235      0.016805      0.007858     -0.005507      0.004270     -0.032287     -0.027608     -0.031251     -0.027722     -0.003179  -0.013631      0.013436      0.002856      0.010075      0.009934     -0.000185      0.005323      0.004587     -0.018987     -0.014783     -0.008103     -0.024049     -0.001469  -0.008501      0.007736     -0.006834      0.015110     -0.010459      0.004565     -0.013803      0.001199     -0.002552     -0.034416     -0.001327     -0.018286     -0.009576  -0.009831     -0.001859     -0.003319      0.017294     -0.010238     -0.008228     -0.001042     -0.005325     -0.015282     -0.018710      0.000953     -0.007519     -0.017366  -0.019141      0.005678      0.004851    

I would run the load process twice for each wave.  The one time to capture the level values and the second time to capture the data and then use the level values as a list to rename the waves.  For the levels, my approach would be capture the whole line as single string and then remove the ":LEVELS:" which leaves you with a semi-colon delisted string that is easy to handle as a list.

I would create a loop that goes over the waves and create a name "Level_"+stringfromlist(index, Levellist)

 

I might create a temp folder to hold the waves and then rename them and move them to a new folder and kill the files in temp folder and repeat as you cycle through all your data.

 

Andy

Depends on if this format is completely fixed or can vary... To make this flexible, I would use:

FReadLine [/N=n /ENCG=textEncoding /T=termcharStr ] refNum, stringVarName

in a loop and read each line separately. Once you hit line containing  :LEVELS:  (use Grepstring or stringMatch) you have the headers. Store that line in temp string. Keep reading until you reach :Data. Now you know the number of lines to skip in the loadwave. Then use the Loadwaves command you have and use default names (make sure they are available by deleting those if needed). Then rename the default named waves into what the names you have from header in simple loop. As far as I can say this is single pass procedure which is also dependent only on use of :LEVELS: and :DATA keywords, it is flexible if number of header lines changes... You could make it simpler by relying on reading third line only and skipping 4 header lines, if the format is fixed. 

I have mostly written a file loader for your file but I can't finish it because text copied from your sample data above is not a reliable representation of the data in your file (e.g., tabs may get turned into spaces).

Please attach a zip archive of a sample data file.

Also let me know what version of Igor you are using.

 

I have attached a file loader for this file.

You should probably put this in your "Igor Procedures" folder so it is always available. Execute this for details:

DisplayHelpTopic "Special Folders"