[ncl-talk] Report of error in web example.

Karin Meier-Fleischer meier-fleischer at dkrz.de
Sun May 15 04:26:32 MDT 2016


Hi Joowan,

you’re right but you can use the newer str_split_csv function to get all elements into a 2D array directly:

begin
  filename = "example1.csv"

  data = asciiread(filename,-1,"string”)
  print("______________")

;-- use str_split_csv to get 2d array
  ncols = dimsizes(str_split(data(0),","))

  values_2d = toint(str_split_csv(data, ",", 0))
  print(values_2d)
  print("______________")

  write_matrix(values_2d,ncols+"I5",False)

end

Terminal output:
 > ncl csv_1.ncl
 Copyright (C) 1995-2015 - All Rights Reserved
 University Corporation for Atmospheric Research
 NCAR Command Language Version 6.3.0
 The use of this software is governed by a License Agreement.
 See http://www.ncl.ucar.edu/ for more details.
(0)	34,67,56
(1)	36,87,78
(2)	31,56,88
(3)	29,67,92
(4)	54,71,68
(5)	42,65,82
(0)	______________


Variable: values_2d
Type: integer
Total Size: 72 bytes
            18 values
Number of Dimensions: 2
Dimensions and sizes:	[6] x [3]
Coordinates: 
Number Of Attributes: 1
  _FillValue :	-2147483647
(0,0)	34
(0,1)	67
(0,2)	56
(1,0)	36
(1,1)	87
(1,2)	78
(2,0)	31
(2,1)	56
(2,2)	88
(3,0)	29
(3,1)	67
(3,2)	92
(4,0)	54
(4,1)	71
(4,2)	68
(5,0)	42
(5,1)	65
(5,2)	82
(0)	______________
  
   34   67   56
   36   87   78
   31   56   88
   29   67   92
   54   71   68
   42   65   82


Bye,
Karin


> Am 15.05.2016 um 07:17 schrieb Joowan Kim <joowan at ucar.edu>:
> 
> Dear whom it concerns,
> 
> Just quick report of error in web example
> "https://www.ncl.ucar.edu/Applications/read_csv.shtml <https://www.ncl.ucar.edu/Applications/read_csv.shtml>"
> 
> In the example page "csv_1.ncl" can NOT reproduce all data in "example1.csv"
> (it only reads first colume of each line and simply repeats. Values in 2nd and 3rd row
> are ignored) I guess it may confuse some people.
> 
> Just FYI
> 
> Best!
> 
> -- 
> Joowan Kim
> National Center for Atmospheric Research
> PO Box 3000  Boulder, CO 80307
> web: http://acd.ucar.edu/~joowan <http://acd.ucar.edu/~joowan>
> email: joowan at ucar.edu <mailto:joowan at ucar.edu>   
>         joowan.k at gmail.com <mailto:joowan.k at gmail.com>
> 
> _______________________________________________
> ncl-talk mailing list
> ncl-talk at ucar.edu
> List instructions, subscriber options, unsubscribe:
> http://mailman.ucar.edu/mailman/listinfo/ncl-talk

____________________________________
Dipl. Geophys. Karin Meier-Fleischer
Visualisierung
Abteilung Anwendungen

Deutsches Klimarechenzentrum GmbH (DKRZ)
Bundesstrasse 45a * D-20146 Hamburg                          
Germany                                

Phone:	+49 (0)40 460094 126
Fax:	+49 (0)40 460094 270
E-Mail:	meier-fleischer at dkrz.de
URL:	http://www.dkrz.de/

Geschäftsführer: Prof. Dr. Thomas Ludwig
Sitz der Gesellschaft: Hamburg
Amtsgericht Hamburg HRB 39784




-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160515/d7684b1e/attachment.html 


More information about the ncl-talk mailing list