title: Putting data into a table using d3.js after a .nest() call
body: <p>I'm fairly certain that I'm making a basic error here, but I can't see where I'm going wrong. I'm gathering data from a csv and using .nest() to roll it up. </p>
  
  <p>I can see from the console that .nest() is processing the data correctly, but it isn't working its way into the html. I'm just getting an empty table. The table is rendering with the correct number of rows and columns, which implies that the data is binding properly, its just not working its way into the html.</p>
  
  <p>Can anyone see where I'm going wrong?</p>
  
  <p>Here's my script:</p>
  
  <pre><code>&lt;div class="pure-g-r box_main" id="r2b2"&gt;
               &lt;script type="text/javascript"&gt; 
  
                              d3.csv("/data/cic_data.csv", function (csv) {
  
                                var data = d3.nest()
                                    .key(function(d) { return d.level2})
                                    .key(function(d) { return d.year})
                                    .rollup(function(d) { 
                                     return d3.sum(d, function(g) {return g.spend; });
                                    }).entries(csv);
  
  
                                var columns = ["region","year","spend"]
  
                                var table = d3.select("#r2b2").append("table").attr("class","pure-table pure-table-striped"),
                                      thead = table.append("thead"),
                                      tbody = table.append("tbody");
  
                                  // append the header row
                                  thead.append("tr")
                                      .selectAll("th")
                                      .data(columns)
                                      .enter()
                                      .append("th")
                                          .text(function(column) { return column; });
  
                                  // create a row for each object in the data
                                  var rows = tbody.selectAll("tr")
                                      .data(data)
                                      .enter()
                                      .append("tr");
  
                                  // create a cell in each row for each column
                                  var cells = rows.selectAll("td")
                                      .data(function(row) {
                                          return columns.map(function(column) {
                                              return {column: column, value: row[column]};
                                          });
                                      })
                                      .enter()
                                      .append("td")
                                          .text(function(d) { return d.value; });
                              });
                          &lt;/script&gt;
                      &lt;/div&gt;
  </code></pre>
  
  <p>And here's a simplified sample of the csv file that I'm processing:</p>
  
  <pre><code>entity_name,level1,level2,Year,Month,Spend
  BEDFORD UNITARY AUTHORITY,Local Government,EAST OF ENGLAND,2014,09,3535
  DEPARTMENT FOR WORK AND PENSIONS (DWP),Central Government,DEPARTMENT FOR WORK AND PENSIONS (DWP),2014,09,123032
  HALTON BOROUGH COUNCIL,Local Government,NORTH WEST,2014,09,1332945
  HARINGEY LONDON BOROUGH COUNCIL,Local Government,LONDON,2014,09,21371
  HOUNSLOW LONDON BOROUGH COUNCIL,Local Government,LONDON,2014,09,4680
  OLDHAM METROPOLITAN BOROUGH COUNCIL,Local Government,NORTH WEST,2014,09,46459
  BARNET LONDON BOROUGH COUNCIL,Local Government,LONDON,2014,08,5727
  BEDFORD UNITARY AUTHORITY,Local Government,EAST OF ENGLAND,2014,08,7071
  BRISTOL CITY COUNCIL,Local Government,SOUTH WEST,2014,08,2000
  BRISTOL CITY COUNCIL,Local Government,SOUTH WEST,2014,08,6657
  BRISTOL CITY COUNCIL,Local Government,SOUTH WEST,2014,08,121072
  BRISTOL CITY COUNCIL,Local Government,SOUTH WEST,2014,08,10000
  BRISTOL CITY COUNCIL,Local Government,SOUTH WEST,2014,08,538118
  </code></pre>