comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Counting header lines in a file
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Counting header lines in a file [message #94624 is a reply to message #94623] Wed, 26 July 2017 07:01 Go to previous message
thtran296 is currently offline  thtran296
Messages: 8
Registered: June 2017
Junior Member
On Wednesday, July 26, 2017 at 8:59:23 AM UTC-4, Matthew Argall wrote:
> Here is how I solved this problem.
> https://github.com/argallmr/IDLlib/blob/master/file_utils/mr file_read_ascii.pro
>
> At the top, there is a helper function called "MrFile_Read_Ascii_Header". It reads each line of the file 1-by-1 until it has read five consecutive lines with the same number of columns. All lines with mismatched number of columns are considered the header. Additionally, the first line of data is parsed to determine its formatting. The output can then be passed to Read_Ascii in the form of a template.
>
> The main program, "MrFile_Read_Ascii", is a wrapper for the Ascii_Template and Read_Ascii procedures and is based off of a program from Mike Galloy.
>
> Hope this helps

I appreciate your help. That really is another great way to do this!
I have figured it out a few days ago but forgot to let you all know.
Basically I used the "strmatch" function to compare the first character of each line with the number 0 to 9. If it doesn't match, then that means the line must have started with a letter, and therefore is a header.
It worked wonderful!
The only caution was that I had to strtrim() each line to make remove the space in front of each line so that strmatch won't compare a space to a number.

Thank you all.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Polar_contour question
Next Topic: error with cgPS_Close Program

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 02:48:01 PDT 2025

Total time taken to generate the page: 2.63852 seconds