Load a text line into a wave

Hello,

I'm trying to read a text file (not a tab delimited text file) with is like that:

# NEW_DATA: 64 data:
64:2: 1 1 1 (etc. there are 640values)
64:3: 102.96 233.25 333.45 (etc. there are 64 values)
64:4: 7.7255 78.39 83.966 (etc. there are 64 values)
64:6: 1.4 1.4 1.4 (etc. there are 64 values)
64:7: 0 0 0 (etc. there are 64 values)
64:8: 300 300 300 (etc. there are 64 values)
# NEW_DATA_SPT : 94 data:
94:2: 1 1 1 1 (etc. there are 94values)
94:3: 102.96 233.25 333.45 252.5 (etc. there are 94 values)


I cut the lines but the idea is that on each line there are a number of data to load which is not constant.
I would like to save these data into a wave.
I'm reading currently all lines, find the space characteres and read the data between two subsequent spaces and load them into a wave.
This is not as smart as I would like to do.

Is there a possibility to read and load data into a wave from a string containing data?

Thanks for your help.
Sébastien
I don't fully understand your question, and it sounds like you have found a reasonable solution, but ...

Quote:
Is there a possibility to read and load data into a wave from a string containing data?

No, but you can store the string in the clipboard using PutScrapText and load it from the clipboard using LoadWave "Clipboard". This is a kludge and overwrites the contents of the clipboard.

Alternatively you can write your data to a temporary file and load it from that. Here is an example:
http://www.igorexchange.com/node/1221

Alternately, you can read your data one line at a time and parse it. This is the least kludgy solution. It sounds like what you are already doing. Here is an example:
http://www.igorexchange.com/node/880
You state that it's not tab delimited so I assume the numbers are separated by a space. While it is not possible to directly load a string into a wave, it can be done with some programming.

You'll be using "Open", "FStatus", "FReadLine", and "Close" to handle each row of the text file individually in a while loop. FReadLine will be used to load a row of the text file into a string while you check FStatus to know if you've reached the end of the file (stop condition).

Now, for each row, after you parse the identifying info (ex. 64:4:) you'll be left with a space delimited list. Now, using "ItemsInList" you'll know how many data values exist in the row currently being evaluated. Using a for loop and "StringFromList" to extract the numbers one at a time and place them in a wave (that you have created to be the same number of points as reported by "ItemsInList") using the "str2num" conversion.
Thanks for your help.
OK, I had the good way to extract my data.
In Matlab, the loop is replaced by a simple sscanf call where all the data are stored in one vector automatically.
Thanks for your precious help.
Sébastien