title: Printing one variable from a netCDF file using Python
body: <p>I am trying to take one variable from a netCDF file and print it. here is my code</p>
  
  <pre><code>import netCDF4
  import netCDF4_utils
  from netCDF4 import Dataset
  from numpy.random import uniform
  import csv
  
  B = []
  rootgrp = Dataset('test.cdf', 'r', format = 'NETCDF4')
  f = open('testoutput.csv','wb')
  
  b = (rootgrp.variables['grid_optical_depth'][:])
  for x in b:
          B.append(x)
  f.write(str(B))
  rootgrp.close()
  f.close()
  </code></pre>
  
  <p>when I run this I get a very large set of data that seems to be repeating, but I don't see how my for loop is doing that, shouldn't it only run through the data set once?
  also could anyone speak to why the data prints out in sets of four per line? If I run <code>print rootgrp.variables['grid_optical_depth']</code> I get</p>
  
  <pre><code>&lt;type 'netCDF4.Variable'&gt;
  float32 grid_optical_depth(grid_time, range)
      long_name: Grid_Aerosol_Optical_Depth_Profile
      units: (n/a)
      temporal_average: 20.0
  unlimited dimensions:
  current shape = (1440, 399)
  </code></pre>
  
  <p>so does that mean that two of the numbers correspond to the grid_time and rage value? I don't think this is the case because all the numbers are much smaller then 1 (on the order of 10^-3 and -4). </p>
  
  <p>Any help is appreciated</p>