code: def gp_datdir(initial, topN):
    inDir, outDir = getWorkDirs()
    initial = initial.capitalize()
    inDir = os.path.join(inDir, initial)
    if not os.path.exists(inDir):
      return "initial %s doesn't exist" % initial
    data = OrderedDict()
    for file in os.listdir(inDir):
      country = os.path.splitext(file)[0]
      file_url = os.path.join(inDir, file)
      data[country] = np.loadtxt(open(file_url, 'rb'))
      data[country][:, 1] /= 1e6
      if data[country].shape[1] > 2: data[country][:, 3:] /= 1e6
    logging.debug(data)
    sorted_data = OrderedDict(sorted(
      data.items(), key = lambda t: np.mean(t[1][:,1]), reverse = True
    ))
    top_data = OrderedDict(
      sorted_data.popitem(last = False) for i in xrange(topN)
      if sorted_data
    )
    nSets = len(top_data)
    make_plot(
      data = top_data.values(),
      properties = [ getOpts(i) for i in xrange(nSets) ],
      titles = top_data.keys(),
      name = os.path.join(outDir, initial),
      key = [ 'at graph 1., 1.2', 'maxrows 2' ],
      ylabel = 'total population ({/Symbol \664} 10^{6})',
      xlabel = 'year', rmargin = 0.99, tmargin = 0.85, size='8.5in,8in'
    )
    return 'done'