title: Working with named tuples to output specific data
body: <p>I am having some trouble working with initializing my data so that I can call specific values by their keys...</p>
  <p>This is my code so far:</p>
  <pre><code>from kafka import KafkaConsumer
  import ast
  from collections import namedtuple
  import json
  import csv
  import sys
  from datetime import datetime
  import os
  
  # connect to kafka topic
  kaf = KafkaConsumer('kafka.topic',
                     auto_offset_reset='earliest', bootstrap_servers=['consumer-kafka.server'])
  outputfile = 'C:\\Users\\Documents\\KafkaConsum\\file.csv'
  
  outfile = open(outputfile, mode='w', newline='')
  
  for row in kaf:
      a = row.value.decode(&quot;utf-8&quot;)
          if &quot;TAG_NAME&quot; in a:
              print(a)
              outfile.write(a + '\n')
  </code></pre>
  <p>This is how my data is formatted:</p>
  <blockquote>
  <p>2018-12-04 13:27:12,511 [a-1
  app=helloname,receiverId=abc-abc-123-123,partner=company] INFO
  kafka.consumer.topic TAG_NAME Type='Generic App' Class= UpdateCheck
  description=Version1  appName=&quot;TWITTER&quot; appAction=&quot;start&quot;</p>
  <p>2018-12-04 13:27:12,511 [a-1
  app=helloname,receiverId=abc-abc-123-123,partner=company] INFO
  kafka.consumer.topic TAG_NAME Type='Generic App' Class= UpdateCheck
  description=Version1  appName=&quot;TWITTER&quot; appAction=&quot;start&quot;</p>
  </blockquote>
  <p>I am looking to be able to parse this data to look like this in my csv file:</p>
  <blockquote>
  <p>app | receiverId | partner | Type | Class | description | appName |
  appAction |</p>
  <p>helloname | abc-abc-123-123 | company | Generic App | UpdateCheck |
  Version1 | TWITTER | start |</p>
  <p>helloname | abc-abc-123-123 | company | Generic App | UpdateCheck |
  Version1 | TWITTER | start |</p>
  </blockquote>