title: How to iterate defaultdict(list) and make a json output in python?
body: <p>How to iterate <code>defaultdict(list)</code> in python in such a way so that I can get counts of each strings sorted by highest number. In my below code, I am reading csv file to</p>
  
  <p>So I read about it and found I can use <code>collections.Counter</code> here but my <code>poc</code> column also has lot of <code>empty/null</code> strings and it is also counting those as well. Is there any way to avoid that? Also can we generate a json with that result if there is any way?</p>
  
  <pre><code>import sys
  import csv
  import collections
  from collections import defaultdict
  
  filename = sys.argv[1]
  columns = defaultdict(list)
  
  with open(filename) as f:
      reader = csv.DictReader(f)
      for row in reader:
          for (k,v) in row.items():
              columns[k].append(v)
  
  print(collections.Counter(columns['poc']))
  </code></pre>
  
  <p>This is the output I get as of now:</p>
  
  <pre><code>Counter({'': 100,'\health':2,'Checking records':2,...})
  </code></pre>