title: Default dict keys to avoid KeyError
body: <p>I'm calling some JSON and parsing relevant data as CSV. I cannot figure out how to fill in the intermediate JSON dict file with default keys, as many are unpopulated. The result is a KeyError as I attempt to parse the content into a CSV.</p>
  <p>I'm now receiving a 'NoneType' error for (manufacturer):</p>
  <pre><code>import urllib2, json, csv, sys, os, codecs, re
  
  from collections import defaultdict
  
  output = 'bb.csv'
  
  csv_writer = csv.writer(open(output, 'w'))
  
  header = ['sku', 'name', 'description', 'image', 'manufacturer', 'upc', 'department', 'class', 'subclass']
  
  csv_writer.writerow(header)
  
  i=1
  
  while i&lt;101:
      print i
  
      bb_url = urllib2.Request(&quot;http://api.remix.bestbuy.com/v1/products(sku=*)?show=sku,name,description,image,manufacturer,upc,department,class,subclass&amp;format=json&amp;sort=sku.asc&amp;page=&quot; + str(i) + &quot;&amp;pageSize=100&amp;apiKey=*****************&quot;)
      bb_json = json.load(urllib2.urlopen(bb_url))
  
      print bb_json
  
      for product in bb_json['products']:
          row = []
  
          row.append(product['sku'])
          if product['name']:
              row.append(str((product['name']).encode('utf-8')))
          else:
              row.append(&quot;&quot;)
          row.append(str(product.get('description',&quot;&quot;)))
          row.append(str(product['image'])+ &quot; &quot;)
          if product['name']:
              row.append(str(product.get('manufacturer',&quot;&quot;).encode('utf-8')))
          else:
              row.append(&quot;&quot;)
          row.append(str(product.get('upc','').encode('utf-8')))
          row.append(str((product['department']).encode('utf-8')))
          row.append(str((product['class']).encode('utf-8')))
          row.append(str((product['subclass']).encode('utf-8')))
  
          csv_writer.writerow(row)
  
      i = i+1
  </code></pre>