;*********************************************************** ; csv_2.ncl ; ; Concepts illustrated: ; - Reading a CSV file ; - Using str_get_field to parse a string ; - Using conversion functions to convert strings to numeric values ; - Reading an ASCII file with delimiters ; ;*********************************************************** ; This is an example of reading a CSV file that has string, ; integer, and float fields. ;*********************************************************** begin filename = "hourly_data.csv" ;---Read in file as array of strings so we can parse each line lines = asciiread(filename,-1,"string") delim = "," ;---Read fields 1, 5, 6, and 11 time = str_get_field(lines,1,delim) wspd = str_get_field(lines,5,delim) wdir = str_get_field(lines,6,delim) Rain = str_get_field(lines,9,delim) Air_Temp = str_get_field(lines,11,delim) ;Time = stringtointeger(time) ;Time@units = "minuts since 2014-10-05 06:00:00" ;dates = cd_calendar(Time, 0) ;print(dates) ;---Print the information print("Time is '" + time + "', wspd is " + wspd + ", wdir is " + wdir + ", Rain is " + Rain + ", Air_Temp is " + Air_Temp) ; --- end