[ncl-talk] reading station data
Dave Allured - NOAA Affiliate
dave.allured at noaa.gov
Fri Feb 6 00:13:47 MST 2026
Debasish, you have almost everything right, except for the position of
field names, and start of data. You have:
field_names = str_split(lines(0),delim)
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.
field_names = str_split(lines(6),delim)
Likewise, data lines start on the next line after the field names, at line
index 7. This should clear up the header errors:
mhs = str_get_field(lines(7:),2,delim) ... etc.
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?
On Thu, Feb 5, 2026 at 9:42 AM Debasish Hazra <debasish.hazra5 at gmail.com>
wrote:
> 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.
>
> Debasish.
>
> On Tue, Feb 3, 2026 at 5:50 PM Dave Allured - NOAA Affiliate <
> dave.allured at noaa.gov> wrote:
>
>> Debasish, that is a CSV file with header lines. Use *asciiread* to read
>> the entire file as strings. Then use string parsing functions such as
>> *str_split_csv* and/or *str_get_field* to get individual columns.
>> Examples *csv_3.ncl* and *csv4_ncl* are close to what you want to do.
>>
>> https://www.ncl.ucar.edu/Applications/read_csv.shtml
>>
>>
>> On Tue, Feb 3, 2026 at 12:38 PM Debasish Hazra via ncl-talk <
>> ncl-talk at mailman.ucar.edu> wrote:
>>
>>> Hi,
>>> 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.
>>> Thanks
>>> Debasish.
>>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.ucar.edu/pipermail/ncl-talk/attachments/20260206/e52811f4/attachment.htm>
More information about the ncl-talk
mailing list