function/wave WDfunc_txt_myTextParser(string filePath) int fileID, eCount=0 string read="" Open/Z/R fileID as filePath if (V_flag) return $"" // failed to open => return nothing endif FReadLine fileID, read // read the first line Close fileID string parse = read, isE do // count the number of 'e' in the first line SplitString/E=("([eE]+)(.*)") parse, isE, parse eCount += strlen(isE) while(strlen(read)) // ----- write output ----- Make/Free/T/N=(4,2) info // 2-col text wave info[][0] = {"tag", "first line", "no. of 'e'", "comments"} // column titles info[0][1] = ParseFilePath(3, filePath, ":", 0, 0) // tag identifies the data => use file name here (could be some other ID) info[1][1] = read // content of the first line info[2][1] = num2str(eCount) // no of 'e' in first line info[3][1] = "" // always empty => comments are entered by the user return info end