Hi. I have a function that loads in waves from multiple text files using LoadWave. Most of the files have a header of a set length so I use the /L flag and set the location of the first line of data. However in a few of the files, the header is a couple of lines longer, this causes LoadWave to start loading the header itself instead of the desired data. The end of the header has a clear deliminator, Is there any way to read the line location of this delimitation so I can make the "first line" variable?
If your data is all numeric, use LoadWave/G, without /L, instead of LoadWave/J. LoadWave/G automatically finds the first line containing data.
Otherwise here is a code snippet that shows how to find the first line: http://www.igorexchange.com/node/4856
In case the automatic detection does not work, the /L flag should do the job. Just parse your file for the end of header delimiter (using FReadLine), count the lines and hand it to the /L flag as a parameter.
HJ
In case the automatic detection does not work, the /L flag should do the job. Just parse your file for the end of header delimiter (using FReadLine), count the lines and hand it to the /L flag as a parameter.
HJ
Thanks, I ended up going with your suggestion and writing a little function to find the start line for the L flag.
Function EndofheaderLoc(path) string path variable refn,i string readstring i=0 open/r refn path do FReadline refn , readstring i+=1 while(strsearch(readstring, "*HeaderEnd*",0,2)<0) returni end
@tony: You are missing the dot before the star in the regexp.
Oops, actually, I forgot to escape the asterisks in the regexp. The asterisks were part of the end-of-header mark in the example given. Edited to correct. Thanks, Thomas.
Otherwise here is a code snippet that shows how to find the first line: http://www.igorexchange.com/node/4856
March 2, 2018 at 09:00 pm - Permalink
FReadLine
), count the lines and hand it to the /L flag as a parameter.HJ
March 6, 2018 at 12:26 pm - Permalink
Thanks, I ended up going with your suggestion and writing a little function to find the start line for the L flag.
string path
variable refn,i
string readstring
i=0
open/r refn path
do
FReadline refn , readstring
i+=1
while (strsearch (readstring, "*HeaderEnd*",0,2)<0)
return i
end
March 13, 2018 at 05:30 pm - Permalink
John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
March 14, 2018 at 09:47 am - Permalink
string path
Grep /Q/E="\*HeaderEnd\*"/Z path
return V_startParagraph
end
March 15, 2018 at 11:55 am - Permalink
March 15, 2018 at 08:37 am - Permalink
Oops, actually, I forgot to escape the asterisks in the regexp. The asterisks were part of the end-of-header mark in the example given. Edited to correct. Thanks, Thomas.
March 15, 2018 at 12:00 pm - Permalink