[ncl-talk] Help: how to just read out one line from a big ascii file?

Xiaofeng Li Xiaofeng.Li at newcastle.ac.uk
Tue Feb 28 04:29:42 MST 2017


Dear All,
        I’m quite confusing how to just read out one or two lines from a big ascii file. Read in all the data into one array and then chose one line from the array seems not working in my current condition.
        For example, how can I just read the second line of the ascii file “asc4.txt”(attached behind) as “string” without loading in all the data into memory first:

The 15 most populous nations
Data taken from Wikipedia, October 2008
----------------------------------------------------------------------
Country         Population (millions)  Percentage (of world)
China           1,321                  19.84%
India           1,132                  16.96%
United States   304                    4.56%
Indonesia       232                    3.47%
Brazil          187                    2.80%
Pakistan        163                    2.44%
Bangladesh      159                    2.38%
Nigeria         148                    2.22%
Russia          142                    2.13%
Japan           128                    1.92%
Mexico          107                    1.60%
Philippines     89                     1.33%
Vietnam         84                     1.31%
Germany         82                     1.23%
Egypt           81                     1.13%
----------------------------------------------------------------------
Total           4,356                  65.32%



       Any help is appreciated.

Best Regards,
Xiao



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170228/7e333948/attachment.html 
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: asc4.txt
Url: http://mailman.ucar.edu/pipermail/ncl-talk/attachments/20170228/7e333948/attachment.txt 


More information about the ncl-talk mailing list