title: How do you convert a multiple arrays of string inside json into csv using python?
body: <p>How do you convert a nested json of multiple arrays into csv tabular structure using python?
  see the complete json <a href="https://spaces.hightail.com/space/yoz24Fi6pB" rel="nofollow noreferrer">here</a></p>
  
  <p>CODE : </p>
  
  <pre><code>import json
  import csv
  
  f = open('cost_drilldown_data.json')
  
  data = json.load(f)
  s=csv.writer(open('costdrillwittime_storage4.csv','w'))
  s.writerow(["filter","cost","value","cost","subvalue","cost","res_id","cost","tot_cost","metdata"])
  i=0
  d = []
  for breakdown in data['breakdown']:
      #for time in data['time']:
          for storage in data['storage']:
               if storage not in d:
  
                  for values in breakdown['values']:
  
                      if 'subvalues' in values:
                           for subvalues in values['subvalues']:
                      #for i in range(0,len(data)):
                              s.writerow([breakdown['filter'],breakdown["cost"],values['value'],values['cost'],
                              subvalues["subvalue"],subvalues["cost"],storage['resource_id'],storage['cost'],
                              storage['total_cost'],storage['metadata']])
  
                      else :
                           s.writerow([breakdown['filter'],"","",values['value'],values['cost']])
  </code></pre>
  
  <p>ACTUAL OUTPUT OF THE ABOVE CODE:</p>
  
  <blockquote>
    <p>filter,cost,value,cost,subvalue,cost,res_id,cost,tot_cost,metdata</p>
    
    <p>tags,5517.734,Name,462.62,BizOps-VM-20,227.576,i-048e0bfa74ac9cf78,25.047,25.801000000000002,{u'name': u'BizOps0424001'}</p>
    
    <p>tags,5517.734,Name,462.62,,70.358,i-048e0bfa74ac9cf78,25.047,25.801000000000002,{u'name':
    u'BizOps0424001'}</p>
    
    <p>tags,5517.734,Name,462.62,BizOps01,60.188,i-048e0bfa74ac9cf78,25.047,25.801000000000002,{u'name':
    u'BizOps0424001'}...</p>
  </blockquote>
  
  <p>its repeating the values of meta data again and again and also repeating the NAME after wards.</p>
  
  <p>how to make print the values only once and differnt values only as per the counts.</p>
  
  <p>see the full csv file <a href="https://spaces.hightail.com/space/U5pEvcPcUJ" rel="nofollow noreferrer">here</a></p>
  
  <blockquote>
    <p><strong>TOTALLY EDITED CODE AFTER ANKUSH's HELP:</strong></p>
  </blockquote>
  
  <pre><code>import json
  import csv
  
  f = open('cost_drilldown_data.json')
  data = json.load(f)
  
  
  s=csv.writer(open('googletry1.csv','w'))
  
  
  breakdown = data['breakdown']
  storage = data['storage']
  filter_list = []            #first column
  filter_cost_list = []       #second column
  value_list = []             #third column
  cost_list = []              #fourth column
  subValue_list = []          #fifth col
  subvalueCost_list = []      #sixth col
  resID_list = []             #seventh col
  storageCost_list = []       #eighth col
  totalCost_list = []         #ninth col
  metadata_list = []          #tenth col
  
  s.writerow(["filter_list","filter_cost_list","value_list","cost_list","subValue_list","subvalueCost_list","resID_list","storageCost_list","totalCost_list","metadata_list"])
  
  for eachBreakdown in breakdown:
      filter_list.append(eachBreakdown['filter'])
      filter_cost_list.append(['cost'])
      valuesArr = eachBreakdown['values']
      for eachValues in valuesArr:
          value_list.append(eachValues['value'])
          cost_list.append(eachValues['cost'])
          if 'subvalues' in eachValues:
              subValueArr = eachValues['subvalues']
          for eachSubValueArr in subValueArr:
              subValue_list.append(eachSubValueArr['subvalue'])
              subvalueCost_list.append(eachSubValueArr['cost'])
  
                      #s.writerow([breakdown['filter'],breakdown["cost"],values['value'],values['cost'],
                      #subvalues["subvalue"],subvalues["cost"],storage['resource_id'],storage['cost'],
                      #storage['total_cost'],storage['metadata'],storage['volume_cost'],storage['provider']])
  
              s.writerow([eachBreakdown['filter'],eachBreakdown['cost'],eachValues['value'],eachValues['cost'],
              eachSubValueArr['subvalue'],eachSubValueArr['cost']])
  
  for eachStorage in storage:
      resID_list.append(eachStorage['resource_id'])
      storageCost_list.append(eachStorage['cost'])
      totalCost_list.append(eachStorage['total_cost'])
      metadata_list.append([eachStorage['metadata']])
  
  
      s.writerow([eachStorage['resource_id']])
  
  
  now i am getting challenge in printing the resource id to the side of the subvalue cost: I am getting csv file as :
  enter code here
  </code></pre>