Extract information from text data file
I have an ascii text data file that has 3000+ lines of information. I am attempting to extract some values from the first "column" of a group of lines near the end of the file. The lines are bracketed by known labels.
I have attempted to do this using the READFILE command in the following approach:
FileDat := READFILE("path to file", "delimited", 1, [1,1])
startline:= match("Data Starts Here", FileDat) + 1
endline:= match("Data Ends Here", FileDat) -1
data:= READFILE("path to file", "delimited", [startline, endline],[1,1],1)
I have two questions:
1) Is there a way to match the full expression, including spaces, in the data file? Right now, it is not matching the "Data Starts Here" - it is only getting the first word "Data". I can correct this by putting underscores in the expression to be matched, and in the data file, but that is a less desirable workaround.
2) I note that the first "READFILE" generates an array (FileDat) that pulls in the first column (or first word or value) from each line in the text file. However, it does not include the blank lines that are in that file. That isn't necessarily a problem, but it does make it so that the startline and endline are based on this "compressed" line numbering. When we get to the second READFILE (where I am trying to extract the actual data I want - which is a set of time points that are the first word/value on the targeted lines), the line numbers from the actual file are used, which include the blank lines. I want to be able to use this for different data files, which do not have predictable line numbering. Is there a way to preserve the full line numbers that include the blank lines in the first READFILE statement, or to be able to reference the compressed line numbering in the second statement?




