<div dir="ltr"><div>To detect the position of the header line, choose a substring in that line that (1) will be included exactly in every file that you want to read, and (2) is very unlikely to be used anywhere else in any file. I like the third header, "Day_of_Year", but most other headers would also be fine. Then locate the line containing this substring.</div><div dir="ltr"><br></div><div> iheader = str_match_ind (line(:) .eq. "Day_of_Year")</div><div> idata = iheader + 1</div><div><br></div><div>Then use these indices in place of the previous hard-coded line indices.</div><div><br></div><div><div> field_names = str_split(lines(iheader),delim)</div><div> mhs = str_get_field(lines(idata:),2,delim) ... etc.</div><br class="gmail-Apple-interchange-newline">If you want to add quality control, you can use ismissing(iheader) to check for missing header line, or unexpected spelling. You might also want to verify that your selected field names are actually the ones that you expected.<br class="gmail-Apple-interchange-newline"></div><div><br></div><div>The problem with the middle column is that you are using an integer format code "%3.0i" to print, but you forgot to convert Day from string to integer. I think you need to use toint(). Printing string with a numeric format code is always good for chaos.</div><div><br></div><br><div class="gmail_quote gmail_quote_container"><div dir="ltr" class="gmail_attr">On Fri, Feb 6, 2026 at 10:07 AM Debasish Hazra <<a href="mailto:debasish.hazra5@gmail.com">debasish.hazra5@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Many thanks Dave. It worked fine. I think I need a way to detect the position automatically as I found it does not always start at line 7, that will be helpful.</div><div>Also, I am trying to write the columns that I read into a csv file, but not getting right for the middle column. Any suggestions? Attached the code and output csv file as well.</div><div><br></div><div>Debasish. </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Feb 6, 2026 at 2:14 AM Dave Allured - NOAA Affiliate <<a href="mailto:dave.allured@noaa.gov" target="_blank">dave.allured@noaa.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr">Debasish, you have almost everything right, except for the position of field names, and start of data. You have:</div><div dir="ltr"><br></div><div dir="ltr"> field_names = str_split(lines(0),delim)</div><div dir="ltr"><br></div><div>But the field names are on line 7, not line 1. Change this to get the field names from line 7. Since NCL uses zero-based indexing, the correct line index is 7 - 1 = 6.</div><div><br></div><div> field_names = str_split(lines(6),delim)</div><div><br></div><div>Likewise, data lines start on the next line after the field names, at line index 7. This should clear up the header errors:</div><div><br></div><div> mhs = str_get_field(lines(7:),2,delim) ... etc.</div><div><br></div><div>If you are processing a lot of data, then the start of data can change between files. Can you have start of data hard coded at 7, or do you need a way to detect the position automatically?</div><div><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Feb 5, 2026 at 9:42 AM Debasish Hazra <<a href="mailto:debasish.hazra5@gmail.com" target="_blank">debasish.hazra5@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Thanks Dave and Dennis for your suggestions. I followed the examples and created a script to read the file I sent earlier, but it seems to be I am still getting some header information in the column I am trying to extract. Attached are output and script that was used, any suggestions to overcome this issue.</div><div><br></div><div>Debasish.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Feb 3, 2026 at 5:50 PM Dave Allured - NOAA Affiliate <<a href="mailto:dave.allured@noaa.gov" target="_blank">dave.allured@noaa.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Debasish, that is a CSV file with header lines. Use <b>asciiread</b> to read the entire file as strings. Then use string parsing functions such as <b>str_split_csv</b> and/or <b>str_get_field</b> to get individual columns. Examples <b>csv_3.ncl</b> and <b>csv4_ncl</b> are close to what you want to do.</div><div><br></div><div> <a href="https://www.ncl.ucar.edu/Applications/read_csv.shtml" target="_blank">https://www.ncl.ucar.edu/Applications/read_csv.shtml</a></div><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Feb 3, 2026 at 12:38 PM Debasish Hazra via ncl-talk <<a href="mailto:ncl-talk@mailman.ucar.edu" target="_blank">ncl-talk@mailman.ucar.edu</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi, </div><div>I am trying to read station data with header and column of data, with COlumn lengths are not equal in files and have attached one example file in the attachment. Can someone help to point what ascii read command to be used to extract time and column information from these files.</div><div>Thanks</div><div>Debasish.</div></div>
</blockquote></div></div>
</blockquote></div>
</blockquote></div></div>
</blockquote></div>
</blockquote></div></div>