<div dir="ltr"><div>Hi Karin and Shea</div><div><br></div><div>Thanks for the informaion, they work pretty well!</div><div>Best,</div><div><br></div><div>Joowan</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, May 16, 2016 at 10:14 AM, Dennis Shea <span dir="ltr">&lt;<a href="mailto:shea@ucar.edu" target="_blank">shea@ucar.edu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Also, there are a few other approaches.<br><br>; two &#39;other&#39; approaches for the simple file<br><br>  filename  = &quot;example1.csv&quot;<br><br>; [1]<br><br>  nrow      = numAsciiRow(filename)<br>  ncol      = 3                                            ; manually specify<br>  values_2d = asciiread(filename,(/nrow,ncol/),&quot;integer&quot;)<br>  write_matrix(values_2d,ncol+&quot;2I5&quot;,False)<br><br>  print(&quot;----&quot;)<br><br>; [2]<br><br>  row_one   = asciiread(filename,1,&quot;string&quot;)         ; read 1st row as string;  ;print(row_one)<br>  NCOL      = str_fields_count(row_one, &quot;,&quot;)<br>  VALUES_2D = asciiread(filename,(/nrow,NCOL/),&quot;integer&quot;)<br>  write_matrix(VALUES_2D, NCOL+&quot;I5&quot; ,False)  <br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Sun, May 15, 2016 at 4:26 AM, Karin Meier-Fleischer <span dir="ltr">&lt;<a href="mailto:meier-fleischer@dkrz.de" target="_blank">meier-fleischer@dkrz.de</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;padding-left:1ex;border-left-color:rgb(204,204,204);border-left-width:1px;border-left-style:solid"><div style="-ms-word-wrap: break-word;"><div>Hi Joowan,</div><div><br></div><div>you’re right but you can use the newer str_split_csv function to get all elements into a 2D array directly:</div><div><div><br></div><div><font color="#002e7a" face="Courier New" size="2">begin</font></div><div><font color="#002e7a" face="Courier New" size="2">  filename = &quot;example1.csv&quot;</font></div><div><font color="#002e7a" face="Courier New" size="2"><br></font></div><div><font color="#002e7a" face="Courier New" size="2">  data = asciiread(filename,-1,&quot;string”)</font></div><div><div><font color="#002e7a" face="Courier New" size="2">  print(&quot;______________&quot;)</font></div></div><div><font color="#002e7a" face="Courier New" size="2"><br></font></div><div><font color="#002e7a" face="Courier New" size="2">;-- use str_split_csv to get 2d array</font></div><div><font color="#002e7a" face="Courier New" size="2">  ncols = dimsizes(str_split(data(0),&quot;,&quot;))</font></div><div><font color="#002e7a" face="Courier New" size="2"><br></font></div><div><font color="#002e7a" face="Courier New" size="2">  values_2d = toint(str_split_csv(data, &quot;,&quot;, 0))</font></div><div><font color="#002e7a" face="Courier New" size="2">  print(values_2d)</font></div><div><font color="#002e7a" face="Courier New" size="2">  print(&quot;______________&quot;)</font></div><div><font color="#002e7a" face="Courier New" size="2"><br></font></div><div><font color="#002e7a" face="Courier New" size="2">  write_matrix(values_2d,ncols+&quot;I5&quot;,False)</font></div><div><font color="#002e7a" face="Courier New" size="2"><br></font></div><div><font color="#002e7a" face="Courier New" size="2">end</font></div></div><div><br></div><div>Terminal output:</div><div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2"> &gt; ncl csv_1.ncl</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2"> Copyright (C) 1995-2015 - All Rights Reserved</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2"> University Corporation for Atmospheric Research</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2"> NCAR Command Language Version 6.3.0</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2"> The use of this software is governed by a License Agreement.</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2"> See <a href="http://www.ncl.ucar.edu/" target="_blank">http://www.ncl.ucar.edu/</a> for more details.</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(0)<span style="white-space:pre-wrap">        </span>34,67,56</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(1)<span style="white-space:pre-wrap">        </span>36,87,78</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(2)<span style="white-space:pre-wrap">        </span>31,56,88</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(3)<span style="white-space:pre-wrap">        </span>29,67,92</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(4)<span style="white-space:pre-wrap">        </span>54,71,68</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(5)<span style="white-space:pre-wrap">        </span>42,65,82</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(0)<span style="white-space:pre-wrap">        </span>______________</font></div><div style="margin:0px;min-height:22px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2"><br></font></div><div style="margin:0px;min-height:22px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2"><br></font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">Variable: values_2d</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">Type: integer</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">Total Size: 72 bytes</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">            18 values</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">Number of Dimensions: 2</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">Dimensions and sizes:<span style="white-space:pre-wrap">        </span>[6] x [3]</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">Coordinates: </font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">Number Of Attributes: 1</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">  _FillValue :<span style="white-space:pre-wrap">        </span>-<a href="tel:2147483647" target="_blank" value="+12147483647">2147483647</a></font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(0,0)<span style="white-space:pre-wrap">        </span>34</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(0,1)<span style="white-space:pre-wrap">        </span>67</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(0,2)<span style="white-space:pre-wrap">        </span>56</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(1,0)<span style="white-space:pre-wrap">        </span>36</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(1,1)<span style="white-space:pre-wrap">        </span>87</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(1,2)<span style="white-space:pre-wrap">        </span>78</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(2,0)<span style="white-space:pre-wrap">        </span>31</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(2,1)<span style="white-space:pre-wrap">        </span>56</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(2,2)<span style="white-space:pre-wrap">        </span>88</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(3,0)<span style="white-space:pre-wrap">        </span>29</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(3,1)<span style="white-space:pre-wrap">        </span>67</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(3,2)<span style="white-space:pre-wrap">        </span>92</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(4,0)<span style="white-space:pre-wrap">        </span>54</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(4,1)<span style="white-space:pre-wrap">        </span>71</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(4,2)<span style="white-space:pre-wrap">        </span>68</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(5,0)<span style="white-space:pre-wrap">        </span>42</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(5,1)<span style="white-space:pre-wrap">        </span>65</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(5,2)<span style="white-space:pre-wrap">        </span>82</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">(0)<span style="white-space:pre-wrap">        </span>______________</font></div><p style="margin:0px;min-height:22px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">  <br></font></p><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">   34   67   56</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">   36   87   78</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">   31   56   88</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">   29   67   92</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">   54   71   68</font></div><div style="margin:0px;background-color:rgb(212,251,121)"><font color="#0042aa" face="Courier New" size="2">   42   65   82</font></div></div><div><br></div><div><br></div><div>Bye,</div><div>Karin</div><div><br></div><br><div><blockquote type="cite"><div><div><div>Am 15.05.2016 um 07:17 schrieb Joowan Kim &lt;<a href="mailto:joowan@ucar.edu" target="_blank">joowan@ucar.edu</a>&gt;:</div><br></div></div><div><div><div><div dir="ltr"><div style="font-size:12.8px">Dear whom it concerns,</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Just quick report of error in web example</div><div style="font-size:12.8px">&quot;<a href="https://www.ncl.ucar.edu/Applications/read_csv.shtml" target="_blank">https://www.ncl.ucar.edu/Applications/read_csv.shtml</a>&quot;</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">In the example page &quot;csv_1.ncl&quot; can NOT reproduce all data in &quot;example1.csv&quot;</div><div style="font-size:12.8px">(it only reads first colume of each line and simply repeats. Values in 2nd and 3rd row</div><div style="font-size:12.8px">are ignored) I guess it may confuse some people.</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Just FYI</div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Best!</div><div><br></div>-- <br><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Joowan Kim<br>National Center for Atmospheric Research<br>PO Box 3000  Boulder, CO 80307<br><div>web: <a href="http://acd.ucar.edu/~joowan" target="_blank">http://acd.ucar.edu/~joowan</a><br></div><div>email: <a href="mailto:joowan@ucar.edu" target="_blank">joowan@ucar.edu</a>   </div><div>        <a href="mailto:joowan.k@gmail.com" target="_blank">joowan.k@gmail.com</a><br></div><div><br></div></div></div></div></div></div></div></div></div></div></div>
</div></div></div>
_______________________________________________<br>ncl-talk mailing list<br><a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>List instructions, subscriber options, unsubscribe:<br><a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br></div></blockquote></div><br><div>
<div style="color:rgb(0,0,0);text-transform:none;text-indent:0px;letter-spacing:normal;word-spacing:0px;white-space:normal"><div style="color:rgb(0,0,0);text-transform:none;line-height:normal;text-indent:0px;letter-spacing:normal;font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;word-spacing:0px;white-space:normal"><div style="color:rgb(0,0,0);text-transform:none;line-height:normal;text-indent:0px;letter-spacing:normal;font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;word-spacing:0px;white-space:normal"><div style="color:rgb(0,0,0);text-transform:none;line-height:normal;text-indent:0px;letter-spacing:normal;font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;word-spacing:0px;white-space:normal"><div style="color:rgb(0,0,0);text-transform:none;line-height:normal;text-indent:0px;letter-spacing:normal;font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;word-spacing:0px;white-space:normal"><span style="border-collapse:separate;border-spacing:0px"><div style="-ms-word-wrap: break-word;"><span style="text-transform:none;line-height:normal;text-indent:0px;letter-spacing:normal;font-family:Helvetica;font-variant:normal;word-spacing:0px;white-space:normal;border-collapse:separate;border-spacing:0px"><div style="-ms-word-wrap: break-word;"><span style="color:rgb(0,0,0);text-transform:none;line-height:normal;text-indent:0px;letter-spacing:normal;font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;word-spacing:0px;white-space:normal;border-collapse:separate;border-spacing:0px"><div style="-ms-word-wrap: break-word;">____________________________________</div></span><span style="font-family:&quot;Courier New&quot;;font-size:13px">Dipl. Geophys. Karin Meier-Fleischer</span></div></span><div><font face="Courier New"><span style="font-size:13px">Visualisierung</span></font></div><div><font face="Courier New"><span style="font-size:13px">Abteilung Anwendungen</span></font></div><div><font face="Courier New"><span style="font-size:13px"><br></span></font></div><div><font face="Courier New"><span style="font-size:13px">Deutsches Klimarechenzentrum GmbH (DKRZ)</span></font></div><div><font face="Courier New"><span style="font-size:13px">Bundesstrasse 45a * D-</span></font><span style="font-family:&quot;Courier New&quot;;font-size:13px">20146 Hamburg                          </span></div><div><font face="Courier New"><span style="font-size:13px">Germany                                </span></font></div><div><font face="Courier New"><span style="font-size:13px"><br></span></font></div><div><span style="font-family:&quot;Courier New&quot;;font-size:13px">Phone:<span style="white-space:pre-wrap">        </span><a href="tel:%2B49%20%280%2940%20460094%20126" target="_blank" value="+4940460094126">+49 (0)40 460094 126</a></span></div><div><div><span style="font-family:&quot;Courier New&quot;;font-size:13px">Fax:<span style="white-space:pre-wrap">        </span><a href="tel:%2B49%20%280%2940%20460094%20270" target="_blank" value="+4940460094270">+49 (0)40 460094 270</a></span></div><div><font face="Courier New"><span style="font-size:13px">E-Mail:<span style="white-space:pre-wrap">        </span></span></font><span style="font-family:&quot;Courier New&quot;;font-size:13px"><a href="mailto:meier-fleischer@dkrz.de" target="_blank">meier-fleischer@dkrz.de</a></span></div></div><div><font face="Courier New"><span style="font-size:13px">URL:<span style="white-space:pre-wrap">        </span></span></font><span style="font-family:&quot;Courier New&quot;;font-size:13px"><a href="http://www.dkrz.de/" target="_blank">http://www.dkrz.de/</a></span></div><div><font face="Courier New"><span style="font-size:13px"><br></span></font></div><div><font face="Courier New"><span style="font-size:13px">Geschäftsführer: Prof. Dr. Thomas Ludwig</span></font></div><div><font face="Courier New"><span style="font-size:13px">Sitz der Gesellschaft: Hamburg</span></font></div><div><font face="Courier New"><span style="font-size:13px">Amtsgericht Hamburg HRB 39784</span></font></div><div><br></div></div></span></div></div></div></div></div><br><br>
</div>
<br></div><br>_______________________________________________<br>
ncl-talk mailing list<br>
<a href="mailto:ncl-talk@ucar.edu" target="_blank">ncl-talk@ucar.edu</a><br>
List instructions, subscriber options, unsubscribe:<br>
<a href="http://mailman.ucar.edu/mailman/listinfo/ncl-talk" target="_blank" rel="noreferrer">http://mailman.ucar.edu/mailman/listinfo/ncl-talk</a><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br><br clear="all"><br>-- <br><div class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr">Joowan Kim<br>National Center for Atmospheric Research<br>PO Box 3000  Boulder, CO 80307<br><div>web: <a href="http://acd.ucar.edu/~joowan" target="_blank">http://acd.ucar.edu/~joowan</a><br></div><div>email: <a href="mailto:joowan@ucar.edu" target="_blank">joowan@ucar.edu</a>   </div><div>        <a href="mailto:joowan.k@gmail.com" target="_blank">joowan.k@gmail.com</a><br></div><div><br></div></div></div></div></div></div></div></div></div></div></div>
</div>