title: Extract RSSI, Lat, Lng for each TagId from log file
body: <p>I have a  txt log file like so, and I want to extract the RSSI values, lat, long for each TagID.</p>
  <pre><code>INFO:received msg from tag : : {&quot;tagId&quot;: &quot;8593e96004019a2e&quot;, &quot;anchor&quot;: [{&quot;RSSI&quot;: -71, &quot;ID&quot;: &quot;P ID  00010c&quot;}, {&quot;RSSI&quot;: -71, &quot;ID&quot;: &quot;P ID  00010e&quot;}, {&quot;RSSI&quot;: -75, &quot;ID&quot;: &quot;P ID  00021d&quot;}, {&quot;RSSI&quot;: -77, &quot;ID&quot;: &quot;P ID  00010a&quot;}, {&quot;RSSI&quot;: -78, &quot;ID&quot;: &quot;P ID  000118&quot;}, {&quot;RSSI&quot;: -85, &quot;ID&quot;: &quot;P ID  00010d&quot;}], &quot;tagData&quot;: {&quot;batteryLevel&quot;: 2.802}}
  INFO:  {&quot;tagId&quot; : &quot;8593e96004019a2e&quot;,&quot;geographic&quot; : { &quot;techno&quot;: &quot;GPS&quot;, &quot;lng&quot;: -3.707135511213621, &quot;lat&quot;: 40.40968001418976, &quot;alt&quot;: 0, &quot;hdop&quot;:3},&quot;tagSensorData&quot; : [{&quot;type&quot; : &quot;batteryLevel&quot;,&quot;value&quot; : &quot;2.802&quot;}]}
  </code></pre>
  <p>And I want to build a csv file as follow:
  tagId   ID  00010a   :ID  00021d     ID  00021f  ID  00010e ID  00010c  ID  00010d   ID  000118 lng lat batteryLevel
  8593e96004019a2e    -71 -81     -90 -81 -77 -90 3.707135511213621   40.40968001418976   2.748
  8593e96004019a2e    -65 -77     -83 -63 -75 -82 3.707135511213621   40.40968001418976   2.808</p>
  <p>I don’t know how to get key, values in python. What is the best solution?
  I’ve tried to export RSSI value but how to get key value?</p>
  <pre><code>import re
  fi = open(&quot;log.txt&quot;, &quot;r&quot;)
  lines = fi.read()
  regex = re.compile('&quot;RSSI&quot;:\s(\-?\d+)')
  out = regex.findall(lines)
  print(out)
  </code></pre>
  <p>I’ve tried to export in json dump but how to get key, value?</p>
  <pre><code>import json
  my_list = [];
  
  with open(‘log.txt') as f:
      lines = f.readlines() # list containing lines of file
      columns = [] # To store column names
  
      i = 1
      for line in lines:
          line = line.strip() # remove leading/trailing white spaces
          if line:
              if i == 1:
                  columns = [item.strip() for item in line.split(';},')]
                  i = i + 1
              else:
                  d = {} # dictionary to store file data (each line)
                  data = [item.strip() for item in line.split(';},')]
                  for index, elem in enumerate(data):
                      d[columns[index]] = data[index]
  
                  my_list.append(d) # append dictionary to list
  #
  print(json.dumps(my_list, indent=4))
  </code></pre>
  <p>Thanks a lot for your help.</p>