<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hey Xiaofeng,<div class="">First, I would suggest you to remove all the rows that are not supposed to be read by NCL (i.e. the header) beforehand, otherwise you'll get into the trouble. If you tell NCL to expect 2 columns of integers when there is 1 of string...you imagine what could result of this :) You can skip the header somehow, but to debug the code it's easier to have fewer complications. </div><div class=""><br class=""></div><div class="">Second, I'm pretty sure that the <font face="Menlo" class="">asciiread</font> procedure (which, I believe, you're using) does not work well with strings AND numeric values on the same row. If you read from the documentation (<a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/asciiread.shtml" class="">http://www.ncl.ucar.edu/Document/Functions/Built-in/asciiread.shtml</a>) "For<span style="color: rgb(51, 51, 51); font-family: verdana, sans-serif; font-size: 13.3333px; orphans: 2; widows: 2; background-color: rgb(255, 255, 255);" class=""> string data, each line of the file is read as a string"</span></div><div class="">So the line begins as a string it would read it as a string. In order to read strings and values you have to read everything as string and then perform a conversion, as explained here (<a href="http://www.ncl.ucar.edu/Applications/read_ascii.shtml#pw" class="">http://www.ncl.ucar.edu/Applications/read_ascii.shtml#pw</a>, see Example for <a href="http://www.ncl.ucar.edu/Applications/Data/asc/istasyontablosu_son.txt" style="margin: 0px; padding: 0px; text-decoration: none; color: rgb(133, 45, 133); font-family: verdana, sans-serif; font-size: 13.3333px; font-variant-ligatures: normal; orphans: 2; widows: 2;" class="">p</a>w.dat file, which is really similar to what you have).</div><div class=""><br class=""></div><div class="">So I would modify your ascii file as follows (you can compute totals afterwards, that's what NCL is meant for):</div><div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" class="">China<span class="Apple-tab-span" style="white-space:pre">                </span>1,321<span class="Apple-tab-span" style="white-space:pre">                </span> 19.84%</font></div><div class=""><font face="Menlo" class="">India<span class="Apple-tab-span" style="white-space:pre">                </span>1,132<span class="Apple-tab-span" style="white-space:pre">                </span> 16.96%</font></div><div class=""><font face="Menlo" class="">United States<span class="Apple-tab-span" style="white-space:pre">        </span>304<span class="Apple-tab-span" style="white-space:pre">                </span> 4.56%</font></div><div class=""><font face="Menlo" class="">Indonesia<span class="Apple-tab-span" style="white-space:pre">        </span>232<span class="Apple-tab-span" style="white-space:pre">                </span> 3.47%</font></div><div class=""><font face="Menlo" class="">Brazil<span class="Apple-tab-span" style="white-space:pre">                </span>187<span class="Apple-tab-span" style="white-space:pre">                </span> 2.80%</font></div><div class=""><font face="Menlo" class="">Pakistan<span class="Apple-tab-span" style="white-space:pre">        </span>163<span class="Apple-tab-span" style="white-space:pre">                </span> 2.44%</font></div><div class=""><font face="Menlo" class="">Bangladesh<span class="Apple-tab-span" style="white-space:pre">        </span>159<span class="Apple-tab-span" style="white-space:pre">                </span> 2.38%</font></div><div class=""><font face="Menlo" class="">Nigeria<span class="Apple-tab-span" style="white-space:pre">                </span>148<span class="Apple-tab-span" style="white-space:pre">                </span> 2.22%</font></div><div class=""><font face="Menlo" class="">Russia<span class="Apple-tab-span" style="white-space:pre">                </span>142<span class="Apple-tab-span" style="white-space:pre">                </span> 2.13%</font></div><div class=""><font face="Menlo" class="">Japan<span class="Apple-tab-span" style="white-space:pre">                </span>128<span class="Apple-tab-span" style="white-space:pre">                </span> 1.92%</font></div><div class=""><font face="Menlo" class="">Mexico<span class="Apple-tab-span" style="white-space:pre">                </span>107<span class="Apple-tab-span" style="white-space:pre">                </span> 1.60%</font></div><div class=""><font face="Menlo" class="">Philippines<span class="Apple-tab-span" style="white-space:pre">        </span>89<span class="Apple-tab-span" style="white-space:pre">                </span> 1.33%</font></div><div class=""><font face="Menlo" class="">Vietnam<span class="Apple-tab-span" style="white-space:pre">                </span>84<span class="Apple-tab-span" style="white-space:pre">                </span> 1.31%</font></div><div class=""><font face="Menlo" class="">Germany<span class="Apple-tab-span" style="white-space:pre">                </span>82<span class="Apple-tab-span" style="white-space:pre">                </span> 1.23%</font></div><div class=""><font face="Menlo" class="">Egypt<span class="Apple-tab-span" style="white-space:pre">                </span>81<span class="Apple-tab-span" style="white-space:pre">                </span> 1.13%</font></div><div class=""><br class=""></div><div class="">and read it as (NOT TESTED): </div><div class=""><br class=""></div><div class=""><pre style="margin-top: 0px; margin-bottom: 0px; padding: 0px; font-size: 13.3333px; line-height: 12pt; font-family: courier; border-style: solid; border-width: 0px 0px 15px; border-color: transparent; font-variant-ligatures: normal; orphans: 2; widows: 2;" class=""> fname = "asc4.txt"
data = <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/asciiread.shtml" style="margin: 0px; padding: 0px; text-decoration: none; color: rgb(133, 45, 133); font-family: verdana, sans-serif;" class=""><strong style="margin: 0px; padding: 0px;" class="">asciiread</strong></a>(fname,-1,"string")
population = <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/stringtofloat.shtml" style="margin: 0px; padding: 0px; text-decoration: none; color: rgb(133, 45, 133); font-family: verdana, sans-serif;" class=""><strong style="margin: 0px; padding: 0px;" class="">stringtofloat</strong></a>(<a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/str_get_field.shtml" style="margin: 0px; padding: 0px; text-decoration: none; color: rgb(133, 45, 133); font-family: verdana, sans-serif;" class=""><strong style="margin: 0px; padding: 0px;" class="">str_get_field</strong></a>(data, 2," "))
precentage = <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/stringtofloat.shtml" style="margin: 0px; padding: 0px; text-decoration: none; color: rgb(133, 45, 133); font-family: verdana, sans-serif;" class=""><strong style="margin: 0px; padding: 0px;" class="">stringtofloat</strong></a>(<a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/str_get_field.shtml" style="margin: 0px; padding: 0px; text-decoration: none; color: rgb(133, 45, 133); font-family: verdana, sans-serif;" class=""><strong style="margin: 0px; padding: 0px;" class="">str_get_field</strong></a>(data, 3," "))
country = <a href="http://www.ncl.ucar.edu/Document/Functions/Built-in/str_get_field.shtml" style="margin: 0px; padding: 0px; text-decoration: none; color: rgb(133, 45, 133); font-family: verdana, sans-serif;" class=""><strong style="margin: 0px; padding: 0px;" class="">str_get_field</strong></a>(data, 1," ")</pre><div class=""><br class=""></div></div><div class="">Carefully read the page <a href="http://www.ncl.ucar.edu/Applications/read_ascii.shtml" class="">http://www.ncl.ucar.edu/Applications/read_ascii.shtml</a>, there are a lot of examples.</div><div class=""><br class=""></div><div class="">Cheers</div><div class=""><br class=""></div><div class="">
<div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class="Apple-interchange-newline">Guido Cioni</div><div style="color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="http://guidocioni.altervista" class="">http://guidocioni.altervista</a>.org</div>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">On 28 Feb 2017, at 12:29, Xiaofeng Li <<a href="mailto:Xiaofeng.Li@newcastle.ac.uk" class="">Xiaofeng.Li@newcastle.ac.uk</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span id="cid:BCB4EFC862A06644858B3CCB21238BF0@eurprd07.prod.outlook.com"><asc4.txt></span></div></blockquote></div><br class=""></div></body></html>