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

Joowan Kim joowan at ucar.edu
Sun May 15 19:58:18 MDT 2016


Hi Karin and Shea

Thanks for the informaion, they work pretty well!
Best,

Joowan

On Mon, May 16, 2016 at 10:14 AM, Dennis Shea <shea at ucar.edu> wrote:

> Also, there are a few other approaches.
>
> ; two 'other' approaches for the simple file
>
>   filename  = "example1.csv"
>
> ; [1]
>
>   nrow      = numAsciiRow(filename)
>   ncol      = 3                                            ; manually
> specify
>   values_2d = asciiread(filename,(/nrow,ncol/),"integer")
>   write_matrix(values_2d,ncol+"2I5",False)
>
>   print("----")
>
> ; [2]
>
>   row_one   = asciiread(filename,1,"string")         ; read 1st row as
> string;  ;print(row_one)
>   NCOL      = str_fields_count(row_one, ",")
>   VALUES_2D = asciiread(filename,(/nrow,NCOL/),"integer")
>   write_matrix(VALUES_2D, NCOL+"I5" ,False)
>
> On Sun, May 15, 2016 at 4:26 AM, Karin Meier-Fleischer <
> meier-fleischer at dkrz.de> wrote:
>
>> 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"
>>
>> 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
>> email: joowan at ucar.edu
>>         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
>>
>>
>>
>>
>>
>> _______________________________________________
>> ncl-talk mailing list
>> ncl-talk at ucar.edu
>> List instructions, subscriber options, unsubscribe:
>> http://mailman.ucar.edu/mailman/listinfo/ncl-talk
>>
>>
>


-- 
Joowan Kim
National Center for Atmospheric Research
PO Box 3000  Boulder, CO 80307
web: http://acd.ucar.edu/~joowan
email: joowan at ucar.edu
        joowan.k at gmail.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20160516/ee7bcd8f/attachment.html 


More information about the ncl-talk mailing list