help to remove NaN points in text waves

I have a bundle of text waves which have Nan values randomly. I want to delete these Nan points, but wavetranform's zapnans only support data wave. So any way to delete these points without using the "delete points" dialog?
You can't have NaNs in a textwave, so i'm assuming you mean empty strings.

Unfortunately, I don't think the conditional operator works on text waves so you'll have to write a little function that uses a for loop to evaluate each element in wave. Something like this should accomplish what you want
wave/t w
variable i
         do
     if(strlen(w[i])==0)
         deletepoints i, 1, w
     endif
     i+=1
    while(i<numpnts(w))


If your text waves contain numbers and NaNs as text, e.g.,
make/t/o ttt={"1","2","nan","3"}

then you can use the following function to clean them up:
Function zapTextNaNs(inWave)
    Wave/T inWave
   
    Make/Free/N=(numpnts(inWave)) tmp
    tmp=str2num(inWave)
    WaveTransform zapNaNs tmp
    Make/o/T/N=(numpnts(tmp)) cleanText
    cleanText=num2str(tmp)
End


If your waves contain something else then please give us more details.

A.G.
WaveMetrics, Inc.
Without scripting as mentioned above the only way to do this is to edit them followed by selecting sections of empty cells and pressing Command/Control-X to cut them from the wave, though this is usually easiest for a smaller number of waves.
wwzhang2 wrote:
Thank you. proland is right, it is empty strings.


Depending on the nature of the text values in your wave (if they are numbers, as AG guessed), AG's solution may still be useful as str2num translates an empty string to NAN.
This is a function I am using to get rid of TRAILING Nans in TextWaves:

// Handy Function to delete trailing NaNs from TextWaves:
Function DeleteNaNTextwave(W)
Wave /T W
Variable i=0, NOP
    Do
    NOP = numpnts(W)
    if((strlen(W [i]) == 0)||(cmpstr("",W [i]) == 0))
        DeletePoints i, 1, W
        i = 0 // Start over again
    else
    i = i+1
    endif  
    while(strlen(w[NOP])==0)
End
This works without starting over, by starting from the end and working toward the beginning.
Function DeleteEmptyCellsFromTextWave(tw)
    Wave/T tw

    Variable numPoints = numpnts(tw)
    Variable i
    for(i=numPoints-1; i>=0; i-=1)
        if (strlen(tw[i]) == 0)
            DeletePoints i, 1, tw
        endif  
    endfor
End