title: CSV WriteRow Data
body: <p>I'm trying to write 2 variables to the rows in my csv. The <code>result</code> variable (which has 2 columns/values), and the 'item<code>variable (which has just 1 value). Can I include both of these values in the</code>writerow` function parameter? If so, how would the syntax look? My syntax below with the comma between the two variables doesn't work. </p>
  
  <p>line I'm talking about:</p>
  
  <pre><code>writer.writerow([item,result.items()[0][0],result.items()[0][1]])
  </code></pre>
  
  <p>All of code:</p>
  
  <pre><code>#!/usr/bin/env python
  
  import splunklib.client as client 
  import splunklib.results as results
  import csv
  
  listOfAppIDs = []
  with open('filefolder/filelocation.txt', 'r') as fi:
      for line in fi:
          listOfAppIDs.append(line.rstrip('\n'))
  listOfAppIDs.sort() #alphebetically sort list
  
  HOST = "ipAddress"
  PORT = 1234
  USERNAME = "uName"
  PASSWORD = "pWord"
  
  startPoint = "firstAppInList" 
  
  outputCsv = open('filefolder/filelocation.csv', 'wb')
  fieldnames = ['appID', 'TotalDestinationIPAddresses', 'AverageThroughputPerMonth']
  writer = csv.DictWriter(outputCsv, fieldnames=fieldnames)
  writer.writeheader(); 
  
  def connect():
      global startPoint , item
  
      service = client.connect(
          host=HOST,
          port=PORT,
          username=USERNAME,
          password=PASSWORD,
          autologin=True
      )   
  
      jobs = service.jobs
      kwargs_blockingsearch = {"exec_mode": "blocking"}
  
      try:
          for item in listOfAppIDs:
              if (item &gt;= startPoint):
                  searchquery_blocking = "splunkQuery"
                  print item + ':'
                  job = jobs.create(searchquery_blocking, **kwargs_blockingsearch) 
              for result in results.ResultsReader(job.results()):             
                  writer.writerow([item,result.items()[0][0],result.items()[0][1]])#writes data underneath the column header
      except csv.Error:
          startPoint = item
          connect()
  
  connect()
  outputCsv.close()
  </code></pre>
  
  <p>ANSWER:</p>
  
  <pre><code>writer.writerow([item,result.items()[0][1],result.items()[1][1]])
  </code></pre>